Class EventHandler
source code
object --+
|
EventHandler
- Known Subclasses:
-
Defines an SL4A event handler and provides a matching function to
compare vs. Android.eventPoll().result
SL4A eventdata returned by Android.eventWait() or
Android.eventPoll().result in general take the form of a dict:
{"data":{"attribute1":value,"attribute2":value},
"name":"event_name", "time":eventtime}
The EventHandler object consists of an event_name, a compare_attribute
to look for within the "data" dict & a compare_value which
the compare_attribute will get matched against. It also has optionally an
event_handler_fn which stores a reference to the method to be called and
the reference to the view referred to by the event.
fullscreenwrapper2 module pre-defines click_EventHandler,
itemclick_EventHandler and key_EventHandler which are commonly used with
Layout views for your convenience
When the FullScreenWrapper2App class which handles events finds a
match, it will call the function defined in the EventHandler passing the
view & a copy of the eventdata. The event handler method signature
should therefore be: def event_handler_function(self, view,
eventdata):
|
|
__init__(self,
event_name,
compare_attribute,
compare_value,
view=None,
handler_function=None)
creates an SL4A event handler |
source code
|
|
|
|
|
|
|
|
|
Inherited from object:
__delattr__,
__format__,
__getattribute__,
__hash__,
__new__,
__reduce__,
__reduce_ex__,
__repr__,
__setattr__,
__sizeof__,
__subclasshook__
|
|
Inherited from object:
__class__
|
__init__(self,
event_name,
compare_attribute,
compare_value,
view=None,
handler_function=None)
(Constructor)
| source code
|
creates an SL4A event handler
SL4A eventdata returned by Android.eventWait() or
Android.eventPoll().result in general take the form of a dict:
{"data":{"attribute1":value,"attribute2":value},
"name":"event_name", "time":eventtime}
The EventHandler object consists of an event_name, a compare_attribute
to look for within the "data" dict & a compare_value which
the compare_attribute will get matched against. It also has optionally an
event_handler_fn which stores a reference to the method to be called and
the reference to the view referred to by the event.
The compare_attribute can be None. if this is the case, then the
event_name alone is matched. You can use this feature to catch other SL4A
API events like sensor events
- Overrides:
object.__init__
|
|
Provides a matching function to compare event handler vs. data
returned by Android.eventPoll().result or Android.eventWait()
SL4A eventdata returned by Android.eventWait() or
Android.eventPoll().result in general take the form of a dict:
{"data":{"attribute1":value,"attribute2":value},
"name":"event_name", "time":eventtime}
The function first matches event_data[event_name] and then tries to
match event_data["data"][compare_attribute] to compare_value
returns True on match, False on no-match or event not found
The compare_attribute can be None. if this is the case, then the
event_name alone is matched. You can use this feature to catch other SL4A
API events like sensor events
|
__str__(self)
(Informal representation operator)
| source code
|
convenience function for debugging
- Overrides:
object.__str__
|