Changes between Version 2 and Version 3 of documentation/PythonManual/AttachingToEvents

Show
Ignore:
Author:
lloydw (IP: 203.96.63.172)
Timestamp:
02/27/08 13:10:44 (10 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • documentation/PythonManual/AttachingToEvents

    v2 v3  
    4141element.AddEventListener('onclick', OnClick, True) 
    4242}}} 
    43  
    44 == Attaching Globally to Contexts == 
    45  
    46 Global Listeners are not encouraged, however sometimes they're useful - mainly for debug tools that need to process key/mouse events across the entire system. When attaching globally from Python you are required to provide an element context from which the event will fire. So that the event can correctly have its document and element states set up. 
    47  
    48 Example: 
    49 {{{ 
    50 context = rocket.GetContext('main') 
    51 context.AddEventListener('click', "print('Global Click!')", context.GetDocument('debugger').GetElementById('window'), False) 
    52 }}} 
    53  
    54 ''NOTE: If you're trying to add a listener to receive clicks for the Game World, rather than attaching globally, make a special document, with an element the size of the screen and lock it to the background. You can then attach mouse/key events to that element and you'll only receive events when the user is not interacting with the foreground interface screens''