Question

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?

Was it helpful?

Solution

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:

 a text
    "..."
      populate: #selection 
      on: $m 
      entitled: 'Implementors' 
      with: [ :text :entity | "logic that retrieves the list of methods" ]

You can see more information at: http://www.themoosebook.org/book/internals/glamour/actions

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top