在 Moose 中,如何通知我按下特殊按键?
在 Moose 中,我希望每当用户在任何文本窗格中按下 Command-M 时我的浏览器都会收到通知。
我正在监听内部端口,等待任何类型的事件。虽然按下 Command-m 时会出现一个文本事件,但它不包含按下 Command-m 的事实。
要进行验证,请在 Moose 中修改 GLMExplicitBrowser>>innerPortEvent:
,添加这是第一条语句:
(aPortEvent port name asString beginsWith: 'select') ifFalse:[ aPortEvent inspect.].
现在在工作区中运行以下命令:
|browser |
browser := GLMBasicExamples new textSelection.
browser openOn: (1 to: 100).
((browser paneNamed: #start) port: #selection) value: 2.
((browser paneNamed: #end) port: #selection) value: 5.
只要文本发生更改,您就会收到通知。如果您按 Command-M,您不会收到通知。如果您接受修改后的文本,您将在文本端口上收到一个端口事件,该事件似乎与常规文本更改没有区别。即:您无法看到文本是否被接受!
我如何获得有关特殊按键和文本接受的通知?
In Moose, I want my browser to be notified whenever a user presses Command-M in any text pane.
I'm listening to the inner port, waiting for any kind of event. While there is a text event that comes in when Command-m is pressed, it doesn't contain the fact that command-m was pressed.
To verify, in Moose, modify GLMExplicitBrowser>>innerPortEvent:
by adding this is a first statement:
(aPortEvent port name asString beginsWith: 'select') ifFalse:[ aPortEvent inspect.].
Now run the following in a workspace:
|browser |
browser := GLMBasicExamples new textSelection.
browser openOn: (1 to: 100).
((browser paneNamed: #start) port: #selection) value: 2.
((browser paneNamed: #end) port: #selection) value: 5.
You get notified whenever the text changes. If you press Command-M, you don't get notified. If you accept the modified text, you get a port event on the text port that seems indistinguishable from regular text changes. I.e.: you can't see if text was accepted or not!
How can I get notified of special key presses, and text acceptances?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自定义用户交互是通过操作来实现的。如果您有兴趣影响浏览器(而不仅仅是执行某些外部操作),那么您希望操作的逻辑影响演示文稿所在端口的值。
例如,如果对于 Command-M 您如果希望获得系统中所有方法的列表,您可以将操作定义为:
您可以在以下位置查看更多信息:
http://www.themoosebook.org/book/internals/glamour/actions
Custom user interaction is achieved through actions. If you are interested in influencing the browser (and not just having some external action executed), then you want the logic of the action to affect the value of the port in which the presentation resides in.
For example, if for Command-M you expect to get a list of all methods in the system, you would define the action as:
You can see more information at:
http://www.themoosebook.org/book/internals/glamour/actions