Class: Wx::GUIEventLoop
- Inherits:
-
Object
- Object
- Wx::GUIEventLoop
- Defined in:
- lib/wx/doc/gen/gui_event_loop.rb
Overview
A generic implementation of the GUI event loop.
Category: Application and Process Management
Instance Method Summary collapse
-
#dispatch ⇒ Boolean
Dispatches the next event in the windowing system event queue.
-
#dispatch_timeout(timeout) ⇒ Integer
Dispatch an event but not wait longer than the specified timeout for it.
-
#exit(rc = 0) ⇒ void
Exit the currently running loop with the given exit code.
- #initialize ⇒ Wx::GUIEventLoop constructor
-
#is_event_allowed_inside_yield(cat) ⇒ Boolean
(also: #event_allowed_inside_yield?)
Returns true if the given event category is allowed inside a #yield_for call (i.e.
-
#is_main ⇒ Boolean
(also: #main?)
Returns true if this is the main loop executed by App#on_run.
-
#is_ok ⇒ Boolean
(also: #ok?)
Use this to check whether the event loop was successfully created before using it.
-
#is_running ⇒ Boolean
(also: #running?)
Return true if this event loop is currently running.
-
#is_yielding ⇒ Boolean
(also: #yielding?)
Returns true if called from inside #yield or from inside #yield_for.
-
#pending ⇒ Boolean
Return true if any events are available.
-
#process_idle ⇒ Boolean
This virtual function is called when the application becomes idle and normally just sends IdleEvent to all interested parties.
-
#run ⇒ Integer
Start the event loop, return the exit code when it is finished.
-
#schedule_exit(rc = 0) ⇒ void
Schedule an exit from the loop with the given exit code.
-
#wake_up ⇒ void
Called by wxWidgets to wake up the event loop even if it is currently blocked inside #dispatch.
-
#wake_up_idle ⇒ void
Makes sure that idle events are sent again.
-
#yield(onlyIfNeeded = false) ⇒ Boolean
Yields control to pending messages in the windowing system.
-
#yield_for(eventsToProcess) ⇒ Boolean
Works like #yield with onlyIfNeeded == true, except that it allows the caller to specify a mask of the EventCategory values which indicates which events should be processed and which should instead be “delayed” (i.e.
Constructor Details
#initialize ⇒ Wx::GUIEventLoop
16 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 16 def initialize; end |
Instance Method Details
#dispatch ⇒ Boolean
Dispatches the next event in the windowing system event queue.
Blocks until an event appears if there are none currently (use #pending if this is not wanted). This can be used for programming event loops, e.g.
while evt_loop.pending
evt_loop.dispatch
false if the event loop should stop and true otherwise.
73 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 73 def dispatch; end |
#dispatch_timeout(timeout) ⇒ Integer
Dispatch an event but not wait longer than the specified timeout for it.
If an event is received before the specified timeout expires, it is processed and the function returns 1 normally or 0 if the event loop should quite. Otherwise, i.e. if the timeout expires, the functions returns -1 without processing any events.
1 if an event was processed, 0 if the event loop should quit or -1 if the timeout expired.
82 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 82 def dispatch_timeout(timeout) end |
#exit(rc = 0) ⇒ void
This method returns an undefined value.
Exit the currently running loop with the given exit code.
The loop will exit, i.e. its #run method will return, during the next event loop iteration. Notice that this method can only be used if this event loop is the currently running one, i.e. its #is_running returns true. If this is not the case, an assert failure is triggered and nothing is done as outer event loops can’t be exited from immediately. Use #schedule_exit if you’d like to exit this loop even if it doesn’t run currently.
43 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 43 def exit(rc=0) end |
#is_event_allowed_inside_yield(cat) ⇒ Boolean Also known as: event_allowed_inside_yield?
Returns true if the given event category is allowed inside a #yield_for call (i.e.
compares the given category against the last mask passed to #yield_for).
129 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 129 def is_event_allowed_inside_yield(cat) end |
#is_main ⇒ Boolean Also known as: main?
Returns true if this is the main loop executed by App#on_run.
134 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 134 def is_main; end |
#is_ok ⇒ Boolean Also known as: ok?
Use this to check whether the event loop was successfully created before using it.
34 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 34 def is_ok; end |
#is_running ⇒ Boolean Also known as: running?
Return true if this event loop is currently running.
Notice that even if this event loop hasn’t terminated yet but has just spawned a nested (e.g. modal) event loop, this method would return false.
29 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 29 def is_running; end |
#is_yielding ⇒ Boolean Also known as: yielding?
Returns true if called from inside #yield or from inside #yield_for.
100 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 100 def is_yielding; end |
#pending ⇒ Boolean
Return true if any events are available.
If this method returns true, calling #dispatch will not block.
57 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 57 def pending; end |
#process_idle ⇒ Boolean
This virtual function is called when the application becomes idle and normally just sends IdleEvent to all interested parties.
It should return true if more idle events are needed, false if not.
96 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 96 def process_idle; end |
#run ⇒ Integer
Start the event loop, return the exit code when it is finished.
Logically, this method calls #dispatch in a loop until it returns false and also takes care of generating idle events during each loop iteration. However not all implementations of this class really implement it like this (e.g. WXGTK does not) so you shouldn’t rely on #dispatch being called from inside this function. The argument passed to #exit which terminated this event loop.
23 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 23 def run; end |
#schedule_exit(rc = 0) ⇒ void
This method returns an undefined value.
Schedule an exit from the loop with the given exit code.
This method is similar to #exit but can be called even if this event loop is not the currently running one and if it is the active loop, then it works in exactly the same way as #exit. The loop will exit as soon as the control flow returns to it, i.e. after any nested loops terminate.
51 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 51 def schedule_exit(rc=0) end |
#wake_up ⇒ void
This method returns an undefined value.
Called by wxWidgets to wake up the event loop even if it is currently blocked inside #dispatch.
86 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 86 def wake_up; end |
#wake_up_idle ⇒ void
This method returns an undefined value.
Makes sure that idle events are sent again.
90 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 90 def wake_up_idle; end |
#yield(onlyIfNeeded = false) ⇒ Boolean
Yields control to pending messages in the windowing system.
This can be useful, for example, when a time-consuming process writes to a text window. Without an occasional yield, the text window will not be updated properly, and on systems with cooperative multitasking, other processes will not respond. Caution should be exercised, however, since yielding may allow the user to perform actions which are not compatible with the current task. Disabling menu items or whole menus during processing can avoid unwanted reentrance of code: see SafeYield for a better function. Note that #yield will not flush the message logs. This is intentional as calling #yield is usually done to quickly update the screen and popping up a message box dialog may be undesirable. If you do wish to flush the log messages immediately (otherwise it will be done during the next idle loop iteration), call Log.flush_active. If onlyIfNeeded parameter is true and the flow control is already inside #yield, i.e. #is_yielding returns true, the method just silently returns false and doesn’t do anything.
111 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 111 def yield(onlyIfNeeded=false) end |
#yield_for(eventsToProcess) ⇒ Boolean
Works like #yield with onlyIfNeeded == true, except that it allows the caller to specify a mask of the EventCategory values which indicates which events should be processed and which should instead be “delayed” (i.e.
processed by the main loop later). Note that this is a safer alternative to #yield since it ensures that only the events you’re interested to will be processed; i.e. this method helps to avoid unwanted reentrancies. Note that currently only WXMSW and WXGTK do support selective yield of native events coming from the underlying GUI toolkit. wxWidgets events posted using EvtHandler#add_pending_event or EvtHandler#queue_event are instead selectively processed by all ports.
121 |
# File 'lib/wx/doc/gen/gui_event_loop.rb', line 121 def yield_for(eventsToProcess) end |