Skip to content

Commit abaee7c

Browse files
committed
fix: context menu
1 parent 7e08f6f commit abaee7c

6 files changed

Lines changed: 112 additions & 184 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = "MIT"
55
description = "Cross platform ui framework"
66
repository = "https://github.com/deft-ui/deft"
77

8-
version = "0.11.0"
8+
version = "0.12.0"
99
authors = ["KasonYang <me@kason.fun>"]
1010
edition = "2021"
1111

examples/gallery/web/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ document.body.appendChild(loadingTip);
2121
loadDeftApp().then((app) => {
2222
document.body.removeChild(loadingTip);
2323
const canvas = document.createElement("canvas");
24+
canvas.addEventListener("contextmenu", (event) => {
25+
event.preventDefault();
26+
})
2427
canvas.style.cssText = "width: 100vw; height: 100vh; display: block;";
2528
document.body.appendChild(canvas);
2629
// Create the WebGL context

js/deft.d.ts

Lines changed: 49 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,21 @@ declare class Process {
318318
* @param code {number}
319319
*/
320320
exit(code: number): void;
321-
get argv(): any;
322-
get isMobilePlatform(): any;
321+
/**
322+
*
323+
* @returns {string[]}
324+
*/
325+
get argv(): string[];
326+
/**
327+
*
328+
* @returns {boolean}
329+
*/
330+
get isMobilePlatform(): boolean;
331+
/**
332+
*
333+
* @returns {string}
334+
*/
335+
get platform(): string;
323336
/**
324337
*
325338
* @param handler {Function}
@@ -344,6 +357,31 @@ declare class Popup {
344357
handle: any;
345358
close(): void;
346359
}
360+
declare class StandardMenuItem {
361+
constructor(label: any, callback: any);
362+
/**
363+
*
364+
* @param value {boolean}
365+
*/
366+
set disabled(value: boolean);
367+
/**
368+
*
369+
* @returns {boolean}
370+
*/
371+
get disabled(): boolean;
372+
get handle(): any;
373+
374+
}
375+
declare class Menu {
376+
/**
377+
*
378+
* @param item {StandardMenuItem}
379+
*/
380+
addStandardItem(item: StandardMenuItem): void;
381+
addSeparator(): void;
382+
get handle(): any;
383+
384+
}
347385
/**
348386
* @typedef {IEvent<ResizeDetail>} IResizeEvent
349387
*/
@@ -394,6 +432,13 @@ declare class Window {
394432
width?: number;
395433
height?: number;
396434
}): Popup;
435+
/**
436+
*
437+
* @param menu {Menu}
438+
* @param x {number}
439+
* @param y {number}
440+
*/
441+
popupMenu(menu: Menu, x: number, y: number): void;
397442
/**
398443
*
399444
* @param message {string | Element}
@@ -648,6 +693,8 @@ declare class Element {
648693
* Request focus on the current element
649694
*/
650695
focus(): void;
696+
set tooltip(text: any);
697+
get tooltip(): any;
651698
/**
652699
* Get the window of element
653700
* @returns {Window}
@@ -974,57 +1021,6 @@ declare class SelectElement extends Element {
9741021
get disabled(): boolean;
9751022
bindChange(callback: any): void;
9761023
}
977-
/**
978-
* @typedef {{
979-
* type: "text",
980-
* text: string,
981-
* weight ?: string,
982-
* textDecorationLine ?: string,
983-
* fontFamilies ?: string[],
984-
* fontSize ?: number,
985-
* color ?: string,
986-
* backgroundColor ?: string
987-
* }} ParagraphUnit
988-
*
989-
* @deprecated
990-
*/
991-
declare class ParagraphElement extends Element {
992-
constructor();
993-
/**
994-
*
995-
* @param units {ParagraphUnit[]}
996-
*/
997-
addLine(units: ParagraphUnit[]): void;
998-
/**
999-
*
1000-
* @param index {number}
1001-
* @param units {ParagraphUnit[]}
1002-
*/
1003-
insertLine(index: number, units: ParagraphUnit[]): void;
1004-
/**
1005-
*
1006-
* @param index {number}
1007-
*/
1008-
deleteLine(index: number): void;
1009-
/**
1010-
*
1011-
* @param index {number}
1012-
* @param units {ParagraphUnit[]}
1013-
*/
1014-
updateLine(index: number, units: ParagraphUnit[]): void;
1015-
clear(): void;
1016-
/**
1017-
*
1018-
* @param units {ParagraphUnit[]}
1019-
* @return {[number, number]}
1020-
*/
1021-
measureLine(units: ParagraphUnit[]): [number, number];
1022-
/**
1023-
*
1024-
* @returns {string | undefined}
1025-
*/
1026-
get selectionText(): string | undefined;
1027-
}
10281024
/**
10291025
* @typedef {{
10301026
* type: "text",
@@ -1078,81 +1074,6 @@ declare class ImageElement extends Element {
10781074
constructor();
10791075
set src(src: any);
10801076
}
1081-
declare class EntryElement extends Element {
1082-
constructor();
1083-
/**
1084-
*
1085-
* @param align {"left"|"right"|"center"}
1086-
*/
1087-
set align(align: "left" | "right" | "center");
1088-
/**
1089-
*
1090-
* @param text {string}
1091-
*/
1092-
set text(text: string);
1093-
/**
1094-
*
1095-
* @returns {string}
1096-
*/
1097-
get text(): string;
1098-
/**
1099-
*
1100-
* @param placeholder {string}
1101-
*/
1102-
set placeholder(placeholder: string);
1103-
get placeholder(): string;
1104-
/**
1105-
*
1106-
* @param style {StyleProps}
1107-
*/
1108-
set placeholderStyle(style: StyleProps);
1109-
/**
1110-
*
1111-
* @returns {StyleProps}
1112-
*/
1113-
get placeholderStyle(): StyleProps;
1114-
/**
1115-
*
1116-
* @param type {"text"|"password"}
1117-
*/
1118-
set type(type: "text" | "password");
1119-
/**
1120-
*
1121-
* @returns {"text" | "password"}
1122-
*/
1123-
get type(): "text" | "password";
1124-
/**
1125-
*
1126-
* @param start {number}
1127-
* @param end {number}
1128-
*/
1129-
setSelectionByCharOffset(start: number, end: number): void;
1130-
/**
1131-
*
1132-
* @param charOffset {number}
1133-
*/
1134-
setCaretByCharOffset(charOffset: number): void;
1135-
/**
1136-
*
1137-
* @param multipleLine {boolean}
1138-
*/
1139-
set multipleLine(multipleLine: boolean);
1140-
/**
1141-
*
1142-
* @param value {boolean}
1143-
*/
1144-
set autoHeight(value: boolean);
1145-
/**
1146-
*
1147-
* @param rows {number}
1148-
*/
1149-
set rows(rows: number);
1150-
set disabled(value: any);
1151-
get disabled(): any;
1152-
bindTextChange(callback: any): void;
1153-
bindCaretChange(callback: any): void;
1154-
1155-
}
11561077
declare class TextInputElement extends Element {
11571078
constructor();
11581079
/**
@@ -1360,16 +1281,6 @@ declare class FetchResponse {
13601281
json(): Promise<any>;
13611282
}
13621283
declare type IResizeEvent = IEvent<ResizeDetail>;
1363-
declare type ParagraphUnit = {
1364-
type: "text";
1365-
text: string;
1366-
weight?: string;
1367-
textDecorationLine?: string;
1368-
fontFamilies?: string[];
1369-
fontSize?: number;
1370-
color?: string;
1371-
backgroundColor?: string;
1372-
};
13731284
declare type TextUnit = {
13741285
type: "text";
13751286
text: string;

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "deft-sys",
3-
"version": "0.10.0",
3+
"version": "0.12.0",
44
"description": "Deft typings",
55
"typings": "deft.d.ts",
66
"scripts": {

lib.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,27 @@ export class Process {
9393
exit(code) {
9494
process_exit(code);
9595
}
96+
97+
/**
98+
*
99+
* @returns {string[]}
100+
*/
96101
get argv() {
97102
return process_argv();
98103
}
104+
105+
/**
106+
*
107+
* @returns {boolean}
108+
*/
99109
get isMobilePlatform() {
100110
return process_is_mobile_platform();
101111
}
102112

113+
/**
114+
*
115+
* @returns {string}
116+
*/
103117
get platform() {
104118
return process_platform();
105119
}

0 commit comments

Comments
 (0)