From 6be45bcb4759e86332a12609687cdcf655f6927d Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Tue, 1 Jan 2019 20:17:56 -0800 Subject: [PATCH] Allow two-click use of menus, like modern GUIs. Fixes #104 --- desktop/desktop_aux.s | 4 ++-- desktop/mgtk.s | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/desktop/desktop_aux.s b/desktop/desktop_aux.s index 9427926..11dcd8b 100644 --- a/desktop/desktop_aux.s +++ b/desktop/desktop_aux.s @@ -5,11 +5,11 @@ ;;; ============================================================ ;;; ============================================================ -;;; Segment loaded into AUX $851F-$BFFF (follows MGTK) +;;; Segment loaded into AUX $8580-$BFFF (follows MGTK) ;;; ============================================================ .proc desktop_aux - .org $851F + .org $8580 ;;; ============================================================ diff --git a/desktop/mgtk.s b/desktop/mgtk.s index 412243e..7f2c2b9 100644 --- a/desktop/mgtk.s +++ b/desktop/mgtk.s @@ -6099,6 +6099,9 @@ cur_open_menu: cur_hilited_menu_item: .byte 0 +was_in_menu_flag: + .byte 0 + .proc MenuSelectImpl PARAM_BLOCK params, $C7 menu_id: .byte 0 @@ -6120,6 +6123,7 @@ menu_item: .byte 0 : lda #0 sta cur_open_menu sta cur_hilited_menu_item + sta was_in_menu_flag jsr get_and_return_event event_loop: bit movement_cancel @@ -6137,10 +6141,16 @@ event_loop: jsr unhilite_cur_menu_item in_menu:jsr get_and_return_event + cmp #MGTK::EventKind::button_down beq :+ cmp #MGTK::EventKind::button_up bne event_loop + bit was_in_menu_flag + bmi :+ + lda cur_open_menu + bne event_loop + : lda cur_hilited_menu_item bne :+ jsr hide_menu @@ -6183,6 +6193,7 @@ in_menu_bar: in_menu_item: lda #find_mode_by_coord + sta was_in_menu_flag sta find_mode jsr find_menu_item cpx cur_hilited_menu_item @@ -10290,3 +10301,9 @@ mouse_operand: ; e.g. if mouse is in slot 4, this is $40 .byte 0 .endproc ; mgtk + + +;;; ============================================================ + + ;; Room for future expansion + PAD_TO $8580