本文整理汇总了C++中Msg_p::swallow方法的典型用法代码示例。如果您正苦于以下问题:C++ Msg_p::swallow方法的具体用法?C++ Msg_p::swallow怎么用?C++ Msg_p::swallow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Msg_p
的用法示例。
在下文中一共展示了Msg_p::swallow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _onMsg
//.........这里部分代码省略.........
m_text.setSelectionMode(true);
if( modKeys & MODKEY_CTRL )
m_text.gotoPrevWord();
else
m_text.goLeft();
break;
case Key::Right:
if( modKeys & MODKEY_SHIFT )
m_text.setSelectionMode(true);
if( modKeys & MODKEY_CTRL )
m_text.gotoNextWord();
else
m_text.goRight();
break;
case Key::Up:
if( modKeys & MODKEY_SHIFT )
m_text.setSelectionMode(true);
m_text.cursorGoUp( 1, globalGeo() );
break;
case Key::Down:
if( modKeys & MODKEY_SHIFT )
m_text.setSelectionMode(true);
m_text.cursorGoDown( 1, globalGeo() );
break;
case Key::Backspace:
if(m_text.hasSelection())
m_text.delSelection();
else if( modKeys & MODKEY_CTRL )
m_text.delPrevWord();
else
m_text.delPrevChar();
break;
case Key::Delete:
if(m_text.hasSelection())
m_text.delSelection();
else if( modKeys & MODKEY_CTRL )
m_text.delNextWord();
else
m_text.delNextChar();
break;
case Key::Home:
if( modKeys & MODKEY_SHIFT )
m_text.setSelectionMode(true);
if( modKeys & MODKEY_CTRL )
m_text.goBot();
else
m_text.goBol();
break;
case Key::End:
if( modKeys & MODKEY_SHIFT )
m_text.setSelectionMode(true);
if( modKeys & MODKEY_CTRL )
m_text.goEot();
else
m_text.goEol();
break;
default:
break;
}
}
// Let text object handle its actions.
/*
bool bChanged = m_text.onAction( action, button_key, globalGeo(), Coord(info.x, info.y) );
if( bChanged )
RequestRender();
*/
// Swallow message depending on rules.
if( pMsg->isMouseButtonMsg() && isSelectable() )
{
if( MouseButtonMsg::cast(pMsg)->button() == MouseButton::Left )
pMsg->swallow();
}
else if( pMsg->isKeyMsg() && isEditable() )
{
Key key = KeyMsg::cast(pMsg)->translatedKeyCode();
if( KeyMsg::cast(pMsg)->isMovementKey() == true ||
key == Key::Delete || key == Key::Backspace || key == Key::Return || (key == Key::Tab && m_bTabLock) )
pMsg->swallow();
//TODO: Would be good if we didn't forward any character-creating keys either...
}
else if( type == MsgType::TextInput )
pMsg->swallow();
}
示例2: _receive
//.........这里部分代码省略.........
{
m_text.goRight();
}
break;
case Key::Backspace:
{
if(m_text.hasSelection())
m_text.delSelection();
else if( (pKeyMsg->modKeys() & MODKEY_CTRL) && !m_bPasswordMode)
m_text.delPrevWord();
else
m_text.delPrevChar();
if( pHandler )
pHandler->post( new TextEditMsg(text.ptr(),false) );
break;
}
case Key::Delete:
{
if(m_text.hasSelection())
m_text.delSelection();
else if( (pKeyMsg->modKeys() & MODKEY_CTRL) && !m_bPasswordMode)
m_text.delNextWord();
else
m_text.delNextChar();
if( pHandler )
pHandler->post( new TextEditMsg(text.ptr(),false) );
break;
}
case Key::Home:
/*
* I am not sure if this is the proper way to this, but in my opinion, the default
* "actions" has to be separated from any modifier key action combination
*/
switch( pKeyMsg->modKeys() )
{
case MODKEY_CTRL:
break;
default: // no modifier key was pressed
if(pKeyMsg->modKeys() & MODKEY_SHIFT )
m_text.setSelectionMode(true);
m_text.goBol();
break;
}
break;
case Key::End:
/*
* I am not sure if this is the proper way to this, but in my opinion, the default
* "actions" has to be separated from any modifier key action combination
*/
switch( pKeyMsg->modKeys() )
{
case MODKEY_CTRL:
break;
default: // no modifier key was pressed
if( pKeyMsg->modKeys() & MODKEY_SHIFT )
m_text.setSelectionMode(true);
m_text.goEol();
break;
}
break;
default:
break;
}
_adjustViewOfs();
}
// Swallow message depending on rules.
if( pMsg->isMouseButtreceive() )
{
if( MouseButtonMsg::cast(pMsg)->button() == MouseButton::Left )
pMsg->swallow();
}
else if( pMsg->isKeyMsg() )
{
Key key = KeyMsg::cast(pMsg)->translatedKeyCode();
if( KeyMsg::cast(pMsg)->isMovementKey() == true ||
key == Key::Delete || key == Key::Backspace )
pMsg->swallow();
//TODO: Would be good if we didn't forward any character-creating keys either...
}
}
示例3: _receive
void Button::_receive( const Msg_p& _pMsg )
{
State state = m_state;
MsgRouter_p pHandler = Base::msgRouter();
switch( _pMsg->type() )
{
case MsgType::KeyPress:
if( KeyPressMsg::cast(_pMsg)->translatedKeyCode() == Key::Return )
{
m_bReturnPressed = true;
_pMsg->swallow();
}
break;
case MsgType::KeyRepeat:
if( KeyRepeatMsg::cast(_pMsg)->translatedKeyCode() == Key::Return )
_pMsg->swallow();
break;
case MsgType::KeyRelease:
if( KeyReleaseMsg::cast(_pMsg)->translatedKeyCode() == Key::Return )
{
m_bReturnPressed = false;
pHandler->post( new SelectMsg(this) );
_pMsg->swallow();
}
break;
case MsgType::MouseEnter:
state.setHovered(true);
break;
case MsgType::MouseLeave:
state.setHovered(false);
break;
case MsgType::MousePress:
if( MousePressMsg::cast(_pMsg)->button() == MouseButton::Left )
{
m_bPressed = true;
_pMsg->swallow();
}
break;
case MsgType::MouseRelease:
if( MouseReleaseMsg::cast(_pMsg)->button() == MouseButton::Left )
{
m_bPressed = false;
_pMsg->swallow();
}
break;
case MsgType::MouseClick:
if( MouseClickMsg::cast(_pMsg)->button() == MouseButton::Left )
{
pHandler->post( new SelectMsg(this) );
_pMsg->swallow();
}
break;
case MsgType::MouseDoubleClick:
case MsgType::MouseRepeat:
case MsgType::MouseDrag:
if( MouseButtonMsg::cast(_pMsg)->button() == MouseButton::Left )
_pMsg->swallow();
break;
case MsgType::FocusGained:
state.setFocused(true);
break;
case MsgType::FocusLost:
state.setFocused(false);
m_bReturnPressed = false;
m_bPressed = false;
break;
default:
break;
}
if( m_bReturnPressed || (m_bPressed && (m_bDownOutside || state.isHovered() )) )
state.setPressed(true);
else
state.setPressed(false);
if( state != m_state )
_setState(state);
}