<?xml version="1.0" encoding="utf-8"?>
<gui:RCPModule xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:gui="cn.smartinvoke.gui.*"
xmlns:rcp="cn.smartinvoke.rcp.*"
layout="vertical" creationComplete="init()">
<mx:Script>
<![CDATA[
import org.eclipse.swt.CEventType;
import cn.smartinvoke.smartrcp.gui.module.CEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
function init():void{
//Display类型对象为单例对象,整个SmartRCP程序共享同一个Display对象,该对象
//为eclipse rcp 程序中的org.eclipse.swt.widgets.Display类型对象对应。
var display:Display=Display.getCurrent();
/**
*添加键盘监听器,此处为键盘按下事件
*/
display.addListener(CEventType.KeyDown,this.onKeyDownEvent,this);
/**
*添加鼠标按下事件
*/
display.addListener(SWT.MouseDown,this.onMouseDownEvent,this);
}
/**
*键盘按下事件的响应函数
*/
function onKeyDownEvent(evt:CEvent):void{
//键盘ctrl + alt + F1组合键
if(evt.stateMask==(SWT.CTRL | SWT.ALT)&& evt.keyCode==SWT.F1){
this.info.text="ctrl + alt + F1 pressed";
}else{
this.info.text=evt.character+" down...";
}
}
/**
*鼠标按下事件的响应函数
*/
function onMouseDownEvent(evt:CEvent):void{
this.info.text="鼠标的第"+evt.button+"个按钮按下了";
}
]]>
</mx:Script>
<mx:Panel title="演示键盘鼠标监听,并且该模块监听ctrl + alt + F1组合键" cornerRadius="0"
horizontalAlign="center" verticalAlign="middle"
styleName="opaquePanel" width="100%" height="100%">
<mx:Label id="info"/>
</mx:Panel>
</gui:RCPModule>
smartrcp键盘右键菜单以及键盘组合键的示例
最新推荐文章于 2014-08-26 17:22:00 发布
本文详细介绍了如何在SmartRCP模块中实现键盘监听和组合键响应功能,通过实例展示了如何使用MXML编写代码以实现特定事件处理逻辑,特别是针对键盘和鼠标事件的响应,特别强调了对`Ctrl + Alt + F1`组合键的监听与处理。
271

被折叠的 条评论
为什么被折叠?



