MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / GUI_Widget_HandleEvents

Function GUI_Widget_HandleEvents

src/gui/widget.c:243–505  ·  view source on GitHub ↗

* Check a widget for events like 'hover' or 'click'. Also check the keyboard * buffer if there was any key which should active us. * * @param w The widget to handle events for. If the widget has a valid next * pointer, those widgets are handled too. * @return The last key pressed, or 0 if the key pressed was handled (or if * there was no key press). */

Source from the content-addressed store, hash-verified

241 * there was no key press).
242 */
243uint16 GUI_Widget_HandleEvents(Widget *w)
244{
245 static Widget *l_widget_selected = NULL;
246 static Widget *l_widget_last = NULL;
247 static uint16 l_widget_button_state = 0x0;
248
249 uint16 mouseX, mouseY;
250 uint16 buttonState;
251 uint16 returnValue;
252 uint16 key;
253 bool fakeClick;
254
255 /* Get the key from the buffer, if there was any key pressed */
256 key = 0;
257 if (Input_IsInputAvailable() != 0) {
258 key = Input_Wait();
259 }
260
261 if (w == NULL) return key & 0x7FFF;
262
263 /* First time this window is being drawn? */
264 if (w != l_widget_last || s_widgetReset) {
265 l_widget_last = w;
266 l_widget_selected = NULL;
267 l_widget_button_state = 0x0;
268 s_widgetReset = false;
269
270 /* Check for left click */
271 if (Input_Test(0x41) != 0) l_widget_button_state |= 0x0200;
272
273 /* Check for right click */
274 if (Input_Test(0x42) != 0) l_widget_button_state |= 0x2000;
275
276 /* Draw all the widgets */
277 for (; w != NULL; w = GUI_Widget_GetNext(w)) {
278 GUI_Widget_Draw(w);
279 }
280 }
281
282 mouseX = g_mouseX;
283 mouseY = g_mouseY;
284
285 buttonState = 0;
286 if (g_mouseDisabled == 0) {
287 uint16 buttonStateChange = 0;
288
289 /* See if the key was a mouse button action */
290 if ((key & 0x8000) != 0) {
291 if ((key & 0x00FF) == 0xC7) buttonStateChange = 0x1000;
292 if ((key & 0x00FF) == 0xC6) buttonStateChange = 0x0100;
293 } else {
294 if ((key & 0x00FF) == 0x42) buttonStateChange = 0x1000;
295 if ((key & 0x00FF) == 0x41) buttonStateChange = 0x0100;
296 }
297
298 /* Mouse button up */
299 if ((key & 0x0800) != 0) {
300 buttonStateChange <<= 2;

Callers 13

GameLoop_MainFunction · 0.85
GUI_PickHouseFunction · 0.85
GUI_DisplayFactoryWindowFunction · 0.85
GUI_HallOfFame_ShowFunction · 0.85
GUI_EditBoxFunction · 0.85
GUI_Mentat_HelpListLoopFunction · 0.85
GUI_Mentat_ShowFunction · 0.85
GUI_Mentat_LoopFunction · 0.85
GUI_YesNoFunction · 0.85
GUI_Widget_Options_ClickFunction · 0.85

Calls 5

Input_IsInputAvailableFunction · 0.85
Input_WaitFunction · 0.85
Input_TestFunction · 0.85
GUI_Widget_GetNextFunction · 0.85
GUI_Widget_DrawFunction · 0.85

Tested by

no test coverage detected