eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'PluggableEventListener':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: PluggableEventListener


Inheritance:

   Object
   |
   +--EventListener
      |
      +--PluggableEventListener

Package:
stx:libview2
Category:
Interface-Support-UI
Version:
rev: 1.5 date: 2022/10/11 14:19:54
user: cg
file: PluggableEventListener.st directory: libview2
module: stx stc-classLibrary: libview2

Description:


a preliminary version of a pluggable event listener.
can be configured via handler blocks.

copyright

COPYRIGHT (c) 2014 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

example

to eat a particular key from another view: |v e| v := StandardSystemView extent:300@200. v add:(e := EditTextView origin:0.0@0.0 corner:1.0@1.0). v label:'key a is ignored'. v openAndWaitUntilVisible. e sensor addEventListener:( PluggableEventListener new keyPressAction:[:event | event key == $a ifTrue:[ Transcript showCR:'a key eaten'. true. ] ifFalse:[ Transcript showCR:'other key ok:',event key printString. false ] ]). to get events for a hotKey (attention: synchronous, so you better enqueue the event into an application's private queue in the handler block) Display rootView addHotKeyHandler:( PluggableEventListener new keyPressAction:[:event | Transcript showCR:event. event key = 'F2' ifTrue:[ Transcript showCR:'F2 pressed'. true. ] ifFalse:[ Transcript showCR:'other key ok:',event key printString. false ] ]) forKey:'F2' modifierMask:nil

Instance protocol:

accessing
o  keyPressAction: aBlock
install a block as handler for keyPress events.
the block will get the windowEvent as argument,
and is supposed to return true if it handled the event,
false if not (so the event is processed as usual).

o  keyReleaseAction: aBlock
install a block as handler for keyRelease events.
the block will get the windowEvent as argument,
and is supposed to return true if it handled the event,
false if not (so the event is processed as usual).

event processing
o  processEvent: anEvent
process an event; if true is returned, the event is considered to be
'eaten' by the listener, and not passed to the view.
If false is returned, the event is processed as usual.
Here, the event is dispatched into one of the button*/key* etc. methods.



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 27 Jul 2024 06:45:09 GMT