java - Events and event handling under the hood -
i've been working through simple programs using sdl , made me think java guis i've written.
in simple sdl programs, have loop checks events (keypresses, mouse clicks etc...) , reacts them. it's polling input.
in java, attach listeners gui objects , listeners triggered when events occur.
my question is, java handle polling loop in background , work out things gui control clicked can trigger correct listener, or there more complex going on?
i know qt has similar event system java use slots connect handler gui control. handling polling , working out control clicked us? or again, there more complex going on?
update
maybe wasn't clear enough question. i'm looking find out how event bridges os layer - application layer boundary. application poll os layer , pull event information application? or os have way interrupt/notify application event has occurred , push event info application.
a third solution has been suggested me application calls blocking native function like:
event e = somenativefunction(); // blocks until somenativefunction() returns event
"...does java handle polling loop in background us...?"
pretty much, yes. ui system provides program access queue contains events have occurred , target. program runs through loop requesting items queue , whatever. libraries qt , java call special functions within widget classes tell them event has happened system can function there, stipulated api. library has translate system specific window id class governing widget in order so.
qt provides access function in form of protected, virtual onxxxxevent()
functions. standard behavior of many widgets generate signals in response events, these translated form of event specific particular widget. qt provides access can override way widget handles event or add additional behavior events never listened before (through subclassing).
each ui system different same in manner in experience. we're talking raw win32 , xlib here.
Comments
Post a Comment