File tree 2 files changed +15
-3
lines changed
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 19
19
<div @contextmenu =" onContextMenu3($event, 'b')" >Bottom Center</div >
20
20
<div @contextmenu =" onContextMenu3($event, 'br')" >Bottom Right</div >
21
21
</div >
22
+ <div class =" box2" style =" width : 170px ; height : 140px " :tabindex =" 1" @contextmenu =" onContextMenu($event)" @keydown =" handleKeyPress" >
23
+ Test keyboard event: Use arrow key to navigate menus.
24
+ <br >
25
+ Down div event catch: {{ testDownDivKey }}
26
+ </div >
22
27
</div >
23
28
<div class =" box1" style =" flex :1 ;padding : 50px " @contextmenu =" onContextMenu1($event)" >
24
29
Test nested menus: Contextmenu In parent
25
- <div class =" box2" style =" width : 170px ; height : 100 px " @contextmenu =" onContextMenu2($event)" >
30
+ <div class =" box2" style =" width : 170px ; height : 50 px " @contextmenu =" onContextMenu2($event)" >
26
31
Contextmenu In child
27
32
</div >
28
33
</div >
@@ -111,6 +116,13 @@ onMounted(() => {
111
116
}).hljs ?.highlightAll ?.();
112
117
});
113
118
119
+ const testDownDivKey = ref (' None' );
120
+
121
+ function handleKeyPress(e : KeyboardEvent ) {
122
+ console .log (' Key press: ' , e .key );
123
+ testDownDivKey .value = e .key ;
124
+ }
125
+
114
126
const members = [
115
127
' 1' ,
116
128
' 2' ,
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ function installBodyEvents() {
140
140
if (! props .isFullScreenContainer && container .value )
141
141
container .value .addEventListener (" scroll" , onBodyScroll , true );
142
142
if (options .value .keyboardControl !== false )
143
- document .addEventListener (' keydown' , onMenuKeyDown );
143
+ document .addEventListener (' keydown' , onMenuKeyDown , true );
144
144
}, 50 );
145
145
}
146
146
function removeBodyEvents() {
@@ -150,7 +150,7 @@ function removeBodyEvents() {
150
150
if (! props .isFullScreenContainer && container .value )
151
151
container .value .removeEventListener (" scroll" , onBodyScroll , true );
152
152
if (options .value .keyboardControl !== false )
153
- document .removeEventListener (' keydown' , onMenuKeyDown );
153
+ document .removeEventListener (' keydown' , onMenuKeyDown , true );
154
154
}
155
155
156
156
// For keyboard event, remember which submenu is active
You can’t perform that action at this time.
0 commit comments