Allow two-click use of menus, like modern GUIs. Fixes #104

This commit is contained in:
Joshua Bell 2019-01-01 20:17:56 -08:00
parent 5d42989909
commit 6be45bcb47
2 changed files with 19 additions and 2 deletions

View File

@ -5,11 +5,11 @@
;;; ============================================================ ;;; ============================================================
;;; ============================================================ ;;; ============================================================
;;; Segment loaded into AUX $851F-$BFFF (follows MGTK) ;;; Segment loaded into AUX $8580-$BFFF (follows MGTK)
;;; ============================================================ ;;; ============================================================
.proc desktop_aux .proc desktop_aux
.org $851F .org $8580
;;; ============================================================ ;;; ============================================================

View File

@ -6099,6 +6099,9 @@ cur_open_menu:
cur_hilited_menu_item: cur_hilited_menu_item:
.byte 0 .byte 0
was_in_menu_flag:
.byte 0
.proc MenuSelectImpl .proc MenuSelectImpl
PARAM_BLOCK params, $C7 PARAM_BLOCK params, $C7
menu_id: .byte 0 menu_id: .byte 0
@ -6120,6 +6123,7 @@ menu_item: .byte 0
: lda #0 : lda #0
sta cur_open_menu sta cur_open_menu
sta cur_hilited_menu_item sta cur_hilited_menu_item
sta was_in_menu_flag
jsr get_and_return_event jsr get_and_return_event
event_loop: event_loop:
bit movement_cancel bit movement_cancel
@ -6137,10 +6141,16 @@ event_loop:
jsr unhilite_cur_menu_item jsr unhilite_cur_menu_item
in_menu:jsr get_and_return_event in_menu:jsr get_and_return_event
cmp #MGTK::EventKind::button_down
beq :+ beq :+
cmp #MGTK::EventKind::button_up cmp #MGTK::EventKind::button_up
bne event_loop bne event_loop
bit was_in_menu_flag
bmi :+
lda cur_open_menu
bne event_loop
: lda cur_hilited_menu_item : lda cur_hilited_menu_item
bne :+ bne :+
jsr hide_menu jsr hide_menu
@ -6183,6 +6193,7 @@ in_menu_bar:
in_menu_item: in_menu_item:
lda #find_mode_by_coord lda #find_mode_by_coord
sta was_in_menu_flag
sta find_mode sta find_mode
jsr find_menu_item jsr find_menu_item
cpx cur_hilited_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 .byte 0
.endproc ; mgtk .endproc ; mgtk
;;; ============================================================
;; Room for future expansion
PAD_TO $8580