当前位置: 首页>>代码示例>>C++>>正文


C++ Msg_p::isKeyMsg方法代码示例

本文整理汇总了C++中Msg_p::isKeyMsg方法的典型用法代码示例。如果您正苦于以下问题:C++ Msg_p::isKeyMsg方法的具体用法?C++ Msg_p::isKeyMsg怎么用?C++ Msg_p::isKeyMsg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Msg_p的用法示例。


在下文中一共展示了Msg_p::isKeyMsg方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _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...
		}
	}
开发者ID:tordj,项目名称:WonderGUI,代码行数:101,代码来源:wg_lineeditor.cpp

示例2: _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();
}
开发者ID:tordj,项目名称:WonderGUI,代码行数:101,代码来源:wg_legacytexteditor.cpp


注:本文中的Msg_p::isKeyMsg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。