本文整理汇总了C++中wxTextCtrl::HitTest方法的典型用法代码示例。如果您正苦于以下问题:C++ wxTextCtrl::HitTest方法的具体用法?C++ wxTextCtrl::HitTest怎么用?C++ wxTextCtrl::HitTest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxTextCtrl
的用法示例。
在下文中一共展示了wxTextCtrl::HitTest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnTextClick
void OnTextClick(wxMouseEvent& event)
{
Field field = Field_Max; // Initialize just to suppress warnings.
long pos;
switch ( m_text->HitTest(event.GetPosition(), &pos) )
{
case wxTE_HT_UNKNOWN:
// Don't do anything, it's better than doing something wrong.
return;
case wxTE_HT_BEFORE:
// Select the first field.
field = Field_Hour;
break;
case wxTE_HT_ON_TEXT:
// Find the field containing this position.
for ( field = Field_Hour; field <= GetLastField(); )
{
const CharRange range = GetFieldRange(field);
// Normally the "to" end is exclusive but we want to give
// focus to some field when the user clicks between them so
// count it as part of the preceding field here.
if ( range.from <= pos && pos <= range.to )
break;
field = static_cast<Field>(field + 1);
}
break;
case wxTE_HT_BELOW:
// This shouldn't happen for single line control.
wxFAIL_MSG( "Unreachable" );
// fall through
case wxTE_HT_BEYOND:
// Select the last field.
field = GetLastField();
break;
}
ChangeCurrentField(field);
}