Events (screen.h)

Events are associated with a given context.

The windowing system manages an event queue per context. An event can be transferred from the event queue to the application by using screen_get_event(). Once transferred to the application, it can be used with screen_get_event_property() in an event handling routine to handle the event accordingly.

Several variations of screen_get_event_property() and screen_set_event_property() functions are available to query and set event properties respectively. It is important to note that different types of events will permit a different selection of properties that can be queried or set. The exception to this is the property which indicates the type of event (SCREEN_PROPERTY_TYPE). Therefore if you have an event to handle, it is common practice in your event handling routine to first query the type of the event using screen_get_event_property_iv() with SCREEN_PROPERTY_TYPE as the name of the property. Once you know which type of event you are handling, you can proceed to call the appropriate query and set API functions for the other event properties. Refer to the example below for the logic of a simple event handling routine.
screen_event_t screen_ev;

	while (1){
		do {
			/* Call screen_get_event with a timeout of -1, or ~0, so that you block
			   until an event is put into the event queue. */
			screen_get_event(screen_ctx, screen_ev, vis ? 0 : ~0);
			/* Get the type of the event */
			screen_get_event_property_iv(screen_ev, SCREEN_PROPERTY_TYPE, &type);

			/* Handle events of interest to your application */
			if (type == SCREEN_EVENT_POST) {
				/* Handle SCREEN_EVENT_POST event accordingly;
				   query or set properties valid for POST events */
			else if (type == SCREEN_EVENT_CLOSE) {
				/* Handle SCREEN_EVENT_CLOSE event accordingly;
				   query or set properties valid for CLOSE events */
			else if
		} while (type != SCREEN_EVENT_NONE);