void ui_checkbox_do( UI_GADGET_CHECKBOX * checkbox, int keypress ) { int OnMe, ButtonLastSelected; keypress = keypress; OnMe = ui_mouse_on_gadget( (UI_GADGET *)checkbox ); checkbox->oldposition = checkbox->position; if ((selected_gadget != NULL) && (selected_gadget->kind !=5)) ButtonLastSelected = 0; else ButtonLastSelected = 1; if ( B1_PRESSED && OnMe && ButtonLastSelected ) { checkbox->position = 1; } else { checkbox->position = 0; } if ((CurWindow->keyboard_focus_gadget==(UI_GADGET *)checkbox) && (keyd_pressed[KEY_SPACEBAR] || keyd_pressed[KEY_ENTER] ) ) checkbox->position = 2; if ((checkbox->position==0) && (checkbox->oldposition==1) && OnMe ) checkbox->pressed = 1; else if ((checkbox->position==0) && (checkbox->oldposition==2) && (CurWindow->keyboard_focus_gadget==(UI_GADGET *)checkbox) ) checkbox->pressed = 1; else checkbox->pressed = 0; if (checkbox->pressed == 1) checkbox->flag ^= 1; ui_draw_checkbox( checkbox ); }
window_event_result ui_checkbox_do( UI_DIALOG *dlg, UI_GADGET_CHECKBOX * checkbox,const d_event &event ) { checkbox->oldposition = checkbox->position; checkbox->pressed = 0; if (event.type == EVENT_MOUSE_BUTTON_DOWN || event.type == EVENT_MOUSE_BUTTON_UP) { int OnMe; OnMe = ui_mouse_on_gadget( checkbox ); if (B1_JUST_PRESSED && OnMe) { checkbox->position = 1; return window_event_result::handled; } else if (B1_JUST_RELEASED) { if ((checkbox->position==1) && OnMe) checkbox->pressed = 1; checkbox->position = 0; } } if (event.type == EVENT_KEY_COMMAND) { int key; key = event_key_get(event); if ((dlg->keyboard_focus_gadget==checkbox) && ((key==KEY_SPACEBAR) || (key==KEY_ENTER)) ) { checkbox->position = 2; return window_event_result::handled; } } else if (event.type == EVENT_KEY_RELEASE) { int key; key = event_key_get(event); checkbox->position = 0; if ((dlg->keyboard_focus_gadget==checkbox) && ((key==KEY_SPACEBAR) || (key==KEY_ENTER)) ) checkbox->pressed = 1; } if (checkbox->pressed == 1) { checkbox->flag ^= 1; auto rval = ui_gadget_send_event(dlg, EVENT_UI_GADGET_PRESSED, checkbox); if (rval == window_event_result::ignored) rval = window_event_result::handled; return rval; } if (event.type == EVENT_WINDOW_DRAW) ui_draw_checkbox( dlg, checkbox ); return window_event_result::ignored; }