mirror of https://github.com/tauri-apps/tauri
fix menu and submenu popup
This commit is contained in:
parent
4ed185fa31
commit
b01da7f3ed
File diff suppressed because one or more lines are too long
|
@ -14,7 +14,7 @@ import { CheckMenuItem } from './checkMenuItem'
|
|||
import { IconMenuItem } from './iconMenuItem'
|
||||
import { PredefinedMenuItem } from './predefinedMenuItem'
|
||||
import { Submenu } from './submenu'
|
||||
import { type LogicalPosition, PhysicalPosition } from '../dpi'
|
||||
import { type LogicalPosition, PhysicalPosition, Position } from '../dpi'
|
||||
import { type Window } from '../window'
|
||||
import { invoke } from '../core'
|
||||
import { type ItemKind, MenuItemBase, newMenu } from './base'
|
||||
|
@ -240,14 +240,14 @@ export class Menu extends MenuItemBase {
|
|||
* If the position, is provided, it is relative to the window's top-left corner.
|
||||
*/
|
||||
async popup(
|
||||
at?: PhysicalPosition | LogicalPosition,
|
||||
at?: PhysicalPosition | LogicalPosition | Position,
|
||||
window?: Window
|
||||
): Promise<void> {
|
||||
return invoke('plugin:menu|popup', {
|
||||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
window: window?.label ?? null,
|
||||
at
|
||||
at: at instanceof Position ? at : at ? new Position(at) : null
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import { invoke } from '../core'
|
|||
import { type LogicalPosition, PhysicalPosition, type Window } from '../window'
|
||||
import { type ItemKind, MenuItemBase, newMenu } from './base'
|
||||
import { type MenuOptions } from './menu'
|
||||
import { Position } from '../dpi'
|
||||
|
||||
function itemFromKind([rid, id, kind]: [number, string, ItemKind]):
|
||||
| Submenu
|
||||
|
@ -247,7 +248,7 @@ export class Submenu extends MenuItemBase {
|
|||
rid: this.rid,
|
||||
kind: this.kind,
|
||||
window: window?.label ?? null,
|
||||
at
|
||||
at: at instanceof Position ? at : at ? new Position(at) : null
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -2312,7 +2312,7 @@ async function availableMonitors(): Promise<Monitor[]> {
|
|||
* The coordinates can be negative if the top-left hand corner of the window is outside of the visible screen region.
|
||||
*/
|
||||
async function cursorPosition(): Promise<PhysicalPosition> {
|
||||
return invoke<{ x: number; y: number }>('plugin:window|cursor_position').then(
|
||||
return invoke<PhysicalPosition>('plugin:window|cursor_position').then(
|
||||
(v) => new PhysicalPosition(v)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue