File tree 2 files changed +11
-18
lines changed
2 files changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -268,8 +268,8 @@ export default class ContextMenu extends Control {
268
268
this . dispatchEvent (
269
269
new ContextMenuEvent ( {
270
270
type : CustomEventTypes . BEFOREOPEN ,
271
- pixel : this . pixel ,
272
- coordinate : this . coordinate ,
271
+ map : this . map ,
272
+ originalEvent : evt
273
273
} )
274
274
) ;
275
275
@@ -281,7 +281,7 @@ export default class ContextMenu extends Control {
281
281
}
282
282
283
283
setTimeout ( ( ) => {
284
- this . openMenu ( ) ;
284
+ this . openMenu ( evt ) ;
285
285
} ) ;
286
286
287
287
evt . target ?. addEventListener (
@@ -296,7 +296,7 @@ export default class ContextMenu extends Control {
296
296
) ;
297
297
}
298
298
299
- protected openMenu ( ) {
299
+ protected openMenu ( evt : MouseEvent ) {
300
300
if ( this . menuEntries . size === 0 ) return ;
301
301
302
302
this . opened = true ;
@@ -306,8 +306,8 @@ export default class ContextMenu extends Control {
306
306
this . dispatchEvent (
307
307
new ContextMenuEvent ( {
308
308
type : CustomEventTypes . OPEN ,
309
- pixel : this . pixel ,
310
- coordinate : this . coordinate ,
309
+ map : this . map ,
310
+ originalEvent : evt
311
311
} )
312
312
) ;
313
313
}
Original file line number Diff line number Diff line change 1
1
import type { Coordinate } from 'ol/coordinate' ;
2
- import type { Pixel } from 'ol/pixel' ;
3
- import { Map as OlMap } from 'ol' ;
4
- import BaseEvent from 'ol/events/Event.js' ;
2
+ import { Map as OlMap , MapBrowserEvent } from 'ol' ;
5
3
6
4
export enum EventTypes {
7
5
CONTEXTMENU = 'contextmenu' ,
@@ -16,18 +14,13 @@ export enum CustomEventTypes {
16
14
ADD_MENU_ENTRY = 'add-menu-entry' ,
17
15
}
18
16
19
- export class ContextMenuEvent extends BaseEvent {
20
- public coordinate : Coordinate ;
21
- public pixel : Pixel ;
22
-
17
+ export class ContextMenuEvent extends MapBrowserEvent < MouseEvent > {
23
18
constructor ( options : {
24
19
type : `${CustomEventTypes . BEFOREOPEN } ` | `${CustomEventTypes . OPEN } `;
25
- coordinate : Coordinate ;
26
- pixel : Pixel ;
20
+ map : OlMap ;
21
+ originalEvent : MouseEvent ;
27
22
} ) {
28
- super ( options . type ) ;
29
- this . pixel = options . pixel ;
30
- this . coordinate = options . coordinate ;
23
+ super ( options . type , options . map , options . originalEvent ) ;
31
24
}
32
25
}
33
26
You can’t perform that action at this time.
0 commit comments