Single api for events and signals on JS side
This commit is contained in:
parent
3d08908f9a
commit
e77ee16c6e
10
demo.ts
10
demo.ts
@ -4,7 +4,7 @@ import { QGridLayout } from "./src/lib/QtWidgets/QGridLayout";
|
||||
import { QLabel } from "./src/lib/QtWidgets/QLabel";
|
||||
import {
|
||||
QPushButton,
|
||||
QPushButtonSignal
|
||||
QPushButtonEvents
|
||||
} from "./src/lib/QtWidgets/QPushButton";
|
||||
import { QCheckBox } from "./src/lib/QtWidgets/QCheckBox";
|
||||
import { QProgressBar } from "./src/lib/QtWidgets/QProgressBar";
|
||||
@ -25,16 +25,16 @@ const testGridLayout = () => {
|
||||
label.setStyleSheet("background-color:blue; color:white;");
|
||||
|
||||
const button1 = new QPushButton();
|
||||
button1.addEventListener(QPushButtonSignal.clicked, isChecked => {
|
||||
button1.addEventListener(QPushButtonEvents.clicked, isChecked => {
|
||||
console.log("clicked", isChecked);
|
||||
});
|
||||
button1.addEventListener(QPushButtonSignal.pressed, (...args) => {
|
||||
button1.addEventListener(QPushButtonEvents.pressed, (...args) => {
|
||||
console.log("pressed", ...args);
|
||||
});
|
||||
button1.addEventListener(QPushButtonSignal.released, (...args) => {
|
||||
button1.addEventListener(QPushButtonEvents.released, (...args) => {
|
||||
console.log("released", ...args);
|
||||
});
|
||||
button1.addEventListener(QPushButtonSignal.toggled, isToggled => {
|
||||
button1.addEventListener(QPushButtonEvents.toggled, isToggled => {
|
||||
console.log("toggled", isToggled);
|
||||
});
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { QWidget } from "../../src/lib/QtGui/QWidget";
|
||||
import { FlexLayout } from "../../src/lib/core/FlexLayout";
|
||||
import {
|
||||
QPushButton,
|
||||
QPushButtonSignal
|
||||
QPushButtonEvents
|
||||
} from "../../src/lib/QtWidgets/QPushButton";
|
||||
import { QLabel } from "../../src/lib/QtWidgets/QLabel";
|
||||
|
||||
@ -20,7 +20,7 @@ const getButton = (
|
||||
const button = new QPushButton();
|
||||
button.setText(label);
|
||||
button.setObjectName(`btn${value}`);
|
||||
button.addEventListener(QPushButtonSignal.clicked, () => {
|
||||
button.addEventListener(QPushButtonEvents.clicked, () => {
|
||||
onBtnClick(value, type);
|
||||
});
|
||||
return {
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
import addon from "../../core/addon";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { BaseWidgetEvents } from "../../core/EventWidget";
|
||||
|
||||
export const QCheckBoxEvents = Object.freeze({
|
||||
...BaseWidgetEvents
|
||||
});
|
||||
export class QCheckBox extends NodeWidget {
|
||||
native: any;
|
||||
constructor(parent?: NodeWidget) {
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import addon from "../../core/addon";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { BaseWidgetEvents } from "../../core/EventWidget";
|
||||
|
||||
export const QLabelEvents = Object.freeze({
|
||||
...BaseWidgetEvents
|
||||
});
|
||||
export class QLabel extends NodeWidget {
|
||||
native: any;
|
||||
constructor(parent?: NodeWidget) {
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import addon from "../../core/addon";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { BaseWidgetEvents } from "../../core/EventWidget";
|
||||
|
||||
export const QLineEditEvents = Object.freeze({
|
||||
...BaseWidgetEvents
|
||||
});
|
||||
export class QLineEdit extends NodeWidget {
|
||||
native: any;
|
||||
constructor(parent?: NodeWidget) {
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
import addon from "../../core/addon";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { FlexNode } from "../../core/FlexLayout/FlexNode";
|
||||
import { BaseWidgetEvents } from "../../core/EventWidget";
|
||||
|
||||
export const QMainWindowEvents = Object.freeze({
|
||||
...BaseWidgetEvents
|
||||
});
|
||||
export class QMainWindow extends NodeWidget {
|
||||
native: any;
|
||||
protected centralWidget?: NodeWidget;
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import addon from "../../core/addon";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { BaseWidgetEvents } from "../../core/EventWidget";
|
||||
|
||||
export const QProgressBarEvents = Object.freeze({
|
||||
...BaseWidgetEvents
|
||||
});
|
||||
export class QProgressBar extends NodeWidget {
|
||||
native: any;
|
||||
constructor(parent?: NodeWidget) {
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
import addon from "../../core/addon";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { BaseWidgetEvents } from "../../core/EventWidget";
|
||||
|
||||
export enum QPushButtonSignal {
|
||||
clicked = "clicked",
|
||||
pressed = "pressed",
|
||||
released = "released",
|
||||
toggled = "toggled"
|
||||
}
|
||||
export const QPushButtonEvents = Object.freeze({
|
||||
...BaseWidgetEvents,
|
||||
clicked: "clicked",
|
||||
pressed: "pressed",
|
||||
released: "released",
|
||||
toggled: "toggled"
|
||||
});
|
||||
|
||||
export class QPushButton extends NodeWidget {
|
||||
native: any;
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import addon from "../../core/addon";
|
||||
import { NodeWidget } from "../../QtGui/QWidget";
|
||||
import { BaseWidgetEvents } from "../../core/EventWidget";
|
||||
|
||||
export const QRadioButtonEvents = Object.freeze({
|
||||
...BaseWidgetEvents
|
||||
});
|
||||
export class QRadioButton extends NodeWidget {
|
||||
native: any;
|
||||
constructor(parent?: NodeWidget) {
|
||||
|
||||
@ -18,3 +18,151 @@ export abstract class EventWidget extends YogaWidget {
|
||||
this.emitter.on(eventType, callback);
|
||||
};
|
||||
}
|
||||
|
||||
export const BaseWidgetEvents = Object.freeze({
|
||||
None: "None",
|
||||
ActionAdded: "ActionAdded",
|
||||
ActionChanged: "ActionChanged",
|
||||
ActionRemoved: "ActionRemoved",
|
||||
ActivationChange: "ActivationChange",
|
||||
ApplicationActivate: "ApplicationActivate",
|
||||
ApplicationActivated: "ApplicationActivated",
|
||||
ApplicationDeactivate: "ApplicationDeactivate",
|
||||
ApplicationFontChange: "ApplicationFontChange",
|
||||
ApplicationLayoutDirectionChange: "ApplicationLayoutDirectionChange",
|
||||
ApplicationPaletteChange: "ApplicationPaletteChange",
|
||||
ApplicationStateChange: "ApplicationStateChange",
|
||||
ApplicationWindowIconChange: "ApplicationWindowIconChange",
|
||||
ChildAdded: "ChildAdded",
|
||||
ChildPolished: "ChildPolished",
|
||||
ChildRemoved: "ChildRemoved",
|
||||
Clipboard: "Clipboard",
|
||||
Close: "Close",
|
||||
CloseSoftwareInputPanel: "CloseSoftwareInputPanel",
|
||||
ContentsRectChange: "ContentsRectChange",
|
||||
ContextMenu: "ContextMenu",
|
||||
CursorChange: "CursorChange",
|
||||
DeferredDelete: "DeferredDelete",
|
||||
DragEnter: "DragEnter",
|
||||
DragLeave: "DragLeave",
|
||||
DragMove: "DragMove",
|
||||
Drop: "Drop",
|
||||
DynamicPropertyChange: "DynamicPropertyChange",
|
||||
EnabledChange: "EnabledChange",
|
||||
Enter: "Enter",
|
||||
EnterWhatsThisMode: "EnterWhatsThisMode",
|
||||
Expose: "Expose",
|
||||
FileOpen: "FileOpen",
|
||||
FocusIn: "FocusIn",
|
||||
FocusOut: "FocusOut",
|
||||
FocusAboutToChange: "FocusAboutToChange",
|
||||
FontChange: "FontChange",
|
||||
Gesture: "Gesture",
|
||||
GestureOverride: "GestureOverride",
|
||||
GrabKeyboard: "GrabKeyboard",
|
||||
GrabMouse: "GrabMouse",
|
||||
GraphicsSceneContextMenu: "GraphicsSceneContextMenu",
|
||||
GraphicsSceneDragEnter: "GraphicsSceneDragEnter",
|
||||
GraphicsSceneDragLeave: "GraphicsSceneDragLeave",
|
||||
GraphicsSceneDragMove: "GraphicsSceneDragMove",
|
||||
GraphicsSceneDrop: "GraphicsSceneDrop",
|
||||
GraphicsSceneHelp: "GraphicsSceneHelp",
|
||||
GraphicsSceneHoverEnter: "GraphicsSceneHoverEnter",
|
||||
GraphicsSceneHoverLeave: "GraphicsSceneHoverLeave",
|
||||
GraphicsSceneHoverMove: "GraphicsSceneHoverMove",
|
||||
GraphicsSceneMouseDoubleClick: "GraphicsSceneMouseDoubleClick",
|
||||
GraphicsSceneMouseMove: "GraphicsSceneMouseMove",
|
||||
GraphicsSceneMousePress: "GraphicsSceneMousePress",
|
||||
GraphicsSceneMouseRelease: "GraphicsSceneMouseRelease",
|
||||
GraphicsSceneMove: "GraphicsSceneMove",
|
||||
GraphicsSceneResize: "GraphicsSceneResize",
|
||||
GraphicsSceneWheel: "GraphicsSceneWheel",
|
||||
Hide: "Hide",
|
||||
HideToParent: "HideToParent",
|
||||
HoverEnter: "HoverEnter",
|
||||
HoverLeave: "HoverLeave",
|
||||
HoverMove: "HoverMove",
|
||||
IconDrag: "IconDrag",
|
||||
IconTextChange: "IconTextChange",
|
||||
InputMethod: "InputMethod",
|
||||
InputMethodQuery: "InputMethodQuery",
|
||||
KeyboardLayoutChange: "KeyboardLayoutChange",
|
||||
KeyPress: "KeyPress",
|
||||
KeyRelease: "KeyRelease",
|
||||
LanguageChange: "LanguageChange",
|
||||
LayoutDirectionChange: "LayoutDirectionChange",
|
||||
LayoutRequest: "LayoutRequest",
|
||||
Leave: "Leave",
|
||||
LeaveWhatsThisMode: "LeaveWhatsThisMode",
|
||||
LocaleChange: "LocaleChange",
|
||||
NonClientAreaMouseButtonDblClick: "NonClientAreaMouseButtonDblClick",
|
||||
NonClientAreaMouseButtonPress: "NonClientAreaMouseButtonPress",
|
||||
NonClientAreaMouseButtonRelease: "NonClientAreaMouseButtonRelease",
|
||||
NonClientAreaMouseMove: "NonClientAreaMouseMove",
|
||||
MacSizeChange: "MacSizeChange",
|
||||
MetaCall: "MetaCall",
|
||||
ModifiedChange: "ModifiedChange",
|
||||
MouseButtonDblClick: "MouseButtonDblClick",
|
||||
MouseButtonPress: "MouseButtonPress",
|
||||
MouseButtonRelease: "MouseButtonRelease",
|
||||
MouseMove: "MouseMove",
|
||||
MouseTrackingChange: "MouseTrackingChange",
|
||||
Move: "Move",
|
||||
NativeGesture: "NativeGesture",
|
||||
OrientationChange: "OrientationChange",
|
||||
Paint: "Paint",
|
||||
PaletteChange: "PaletteChange",
|
||||
ParentAboutToChange: "ParentAboutToChange",
|
||||
ParentChange: "ParentChange",
|
||||
PlatformPanel: "PlatformPanel",
|
||||
PlatformSurface: "PlatformSurface",
|
||||
Polish: "Polish",
|
||||
PolishRequest: "PolishRequest",
|
||||
QueryWhatsThis: "QueryWhatsThis",
|
||||
ReadOnlyChange: "ReadOnlyChange",
|
||||
RequestSoftwareInputPanel: "RequestSoftwareInputPanel",
|
||||
Resize: "Resize",
|
||||
ScrollPrepare: "ScrollPrepare",
|
||||
Scroll: "Scroll",
|
||||
Shortcut: "Shortcut",
|
||||
ShortcutOverride: "ShortcutOverride",
|
||||
Show: "Show",
|
||||
ShowToParent: "ShowToParent",
|
||||
SockAct: "SockAct",
|
||||
StateMachineSignal: "StateMachineSignal",
|
||||
StateMachineWrapped: "StateMachineWrapped",
|
||||
StatusTip: "StatusTip",
|
||||
StyleChange: "StyleChange",
|
||||
TabletMove: "TabletMove",
|
||||
TabletPress: "TabletPress",
|
||||
TabletRelease: "TabletRelease",
|
||||
TabletEnterProximity: "TabletEnterProximity",
|
||||
TabletLeaveProximity: "TabletLeaveProximity",
|
||||
TabletTrackingChange: "TabletTrackingChange",
|
||||
ThreadChange: "ThreadChange",
|
||||
Timer: "Timer",
|
||||
ToolBarChange: "ToolBarChange",
|
||||
ToolTip: "ToolTip",
|
||||
ToolTipChange: "ToolTipChange",
|
||||
TouchBegin: "TouchBegin",
|
||||
TouchCancel: "TouchCancel",
|
||||
TouchEnd: "TouchEnd",
|
||||
TouchUpdate: "TouchUpdate",
|
||||
UngrabKeyboard: "UngrabKeyboard",
|
||||
UngrabMouse: "UngrabMouse",
|
||||
UpdateLater: "UpdateLater",
|
||||
UpdateRequest: "UpdateRequest",
|
||||
WhatsThis: "WhatsThis",
|
||||
WhatsThisClicked: "WhatsThisClicked",
|
||||
Wheel: "Wheel",
|
||||
WinEventAct: "WinEventAct",
|
||||
WindowActivate: "WindowActivate",
|
||||
WindowBlocked: "WindowBlocked",
|
||||
WindowDeactivate: "WindowDeactivate",
|
||||
WindowIconChange: "WindowIconChange",
|
||||
WindowStateChange: "WindowStateChange",
|
||||
WindowTitleChange: "WindowTitleChange",
|
||||
WindowUnblocked: "WindowUnblocked",
|
||||
WinIdChange: "WinIdChange",
|
||||
ZOrderChange: "ZOrderChange"
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user