29 namespace JSEventUtils
31 KJS::JSObject *
event( KJS::ExecState *exec,
const QEvent *ev )
41 case QEvent::MouseButtonPress:
42 case QEvent::MouseButtonRelease:
43 case QEvent::MouseButtonDblClick:
44 case QEvent::MouseMove:
49 case QEvent::KeyPress:
50 case QEvent::KeyRelease:
54 case QEvent::FocusOut:
71 case QEvent::ParentChange:
72 case QEvent::ParentAboutToChange:
73 case QEvent::ThreadChange:
74 case QEvent::WindowActivate:
75 case QEvent::WindowDeactivate:
76 case QEvent::ShowToParent:
77 case QEvent::HideToParent:
79 case QEvent::WindowTitleChange:
80 case QEvent::WindowIconChange:
81 case QEvent::ApplicationWindowIconChange:
82 case QEvent::ApplicationFontChange:
83 case QEvent::ApplicationLayoutDirectionChange:
84 case QEvent::ApplicationPaletteChange:
85 case QEvent::PaletteChange:
86 case QEvent::Clipboard:
88 case QEvent::MetaCall:
91 case QEvent::DeferredDelete:
92 case QEvent::DragEnter:
93 case QEvent::DragMove:
94 case QEvent::DragLeave:
96 case QEvent::DragResponse:
97 case QEvent::ChildAdded:
98 case QEvent::ChildPolished:
99 case QEvent::ChildRemoved:
100 case QEvent::ShowWindowRequest:
101 case QEvent::PolishRequest:
103 case QEvent::LayoutRequest:
104 case QEvent::UpdateRequest:
105 case QEvent::EmbeddingControl:
106 case QEvent::ActivateControl:
107 case QEvent::DeactivateControl:
108 case QEvent::ContextMenu:
109 case QEvent::InputMethod:
110 case QEvent::AccessibilityPrepare:
111 case QEvent::TabletMove:
112 case QEvent::LocaleChange:
113 case QEvent::LanguageChange:
114 case QEvent::LayoutDirectionChange:
116 case QEvent::TabletPress:
117 case QEvent::TabletRelease:
118 case QEvent::OkRequest:
119 case QEvent::HelpRequest:
120 case QEvent::IconDrag:
121 case QEvent::FontChange:
122 case QEvent::EnabledChange:
123 case QEvent::ActivationChange:
124 case QEvent::StyleChange:
125 case QEvent::IconTextChange:
126 case QEvent::ModifiedChange:
127 case QEvent::MouseTrackingChange:
128 case QEvent::WindowBlocked:
129 case QEvent::WindowUnblocked:
130 case QEvent::WindowStateChange:
131 case QEvent::ToolTip:
132 case QEvent::WhatsThis:
133 case QEvent::StatusTip:
134 case QEvent::ActionChanged:
135 case QEvent::ActionAdded:
136 case QEvent::ActionRemoved:
137 case QEvent::FileOpen:
138 case QEvent::Shortcut:
139 case QEvent::ShortcutOverride:
140 case QEvent::WhatsThisClicked:
141 case QEvent::ToolBarChange:
142 case QEvent::ApplicationActivated:
143 case QEvent::ApplicationDeactivated:
144 case QEvent::QueryWhatsThis:
145 case QEvent::EnterWhatsThisMode:
146 case QEvent::LeaveWhatsThisMode:
147 case QEvent::ZOrderChange:
148 case QEvent::HoverEnter:
149 case QEvent::HoverLeave:
150 case QEvent::HoverMove:
151 case QEvent::AccessibilityHelp:
152 case QEvent::AccessibilityDescription:
162 evnt->put( exec,
"type", KJS::jsNumber( (
int) ev->type()) );
163 evnt->put( exec,
"spontaneous", KJS::jsBoolean(ev->spontaneous()) );
164 evnt->put( exec,
"isAccepted", KJS::jsBoolean(ev->isAccepted()) );
168 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QInputEvent *ev)
170 KJS::JSObject *iev =
convertEvent( exec, (QEvent *)ev );
171 iev->put( exec,
"modifiers", KJS::jsNumber( ev->modifiers() ));
175 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QMouseEvent *ev)
177 KJS::JSObject *mev =
convertEvent( exec, (QInputEvent *)ev );
180 mev->put( exec,
"x", KJS::jsNumber( ev->x() ));
181 mev->put( exec,
"y", KJS::jsNumber( ev->y() ));
183 mev->put( exec,
"globalPos",
convertToValue( exec, ev->globalPos() ));
184 mev->put( exec,
"globalX", KJS::jsNumber( ev->globalX() ));
185 mev->put( exec,
"globalY", KJS::jsNumber( ev->globalY() ));
187 mev->put( exec,
"button", KJS::jsNumber(ev->button()) );
188 mev->put( exec,
"buttons", KJS::jsNumber(ev->buttons()) );
193 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QPaintEvent *ev)
195 KJS::JSObject *pev =
convertEvent( exec, (QEvent *)ev );
202 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QKeyEvent *ev)
204 KJS::JSObject *kev =
convertEvent( exec, (QInputEvent *)ev );
206 kev->put( exec,
"key", KJS::jsNumber(ev->key()) );
208 kev->put( exec,
"isAutoRepeat", KJS::jsBoolean(ev->isAutoRepeat()) );
209 kev->put( exec,
"count", KJS::jsNumber( ev->count()) );
213 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QInputMethodEvent *ev)
215 KJS::JSObject *qev =
convertEvent( exec, (QEvent *)ev );
217 qev->put( exec,
"commitString",
KJS::jsString(ev->commitString()) );
218 qev->put( exec,
"preeditString",
KJS::jsString(ev->preeditString()) );
219 qev->put( exec,
"replacementLength", KJS::jsNumber(ev->replacementLength()) );
220 qev->put( exec,
"replacementStart", KJS::jsNumber(ev->replacementStart()) );
224 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QResizeEvent *ev)
226 KJS::JSObject *rev =
convertEvent( exec, (QEvent *)ev );
229 rev->put( exec,
"oldSize",
convertToValue( exec, ev->oldSize() ));
233 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QCloseEvent *ev)
235 KJS::JSObject *cev =
convertEvent( exec, (QEvent *)ev );
237 cev->put( exec,
"isAccepted", KJS::jsBoolean(ev->isAccepted()) );
241 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QMoveEvent *ev)
243 KJS::JSObject *mev =
convertEvent( exec, (QEvent *)ev );
250 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QWheelEvent *ev)
252 KJS::JSObject *wev =
convertEvent( exec, (QInputEvent *)ev );
254 wev->put( exec,
"delta", KJS::jsNumber(ev->delta()) );
256 wev->put( exec,
"globalPos",
convertToValue( exec, ev->globalPos() ) );
257 wev->put( exec,
"x", KJS::jsNumber(ev->x()) );
258 wev->put( exec,
"y", KJS::jsNumber(ev->y()) );
259 wev->put( exec,
"globalX", KJS::jsNumber(ev->globalX()) );
260 wev->put( exec,
"globalY", KJS::jsNumber(ev->globalY()) );
261 wev->put( exec,
"orientation", KJS::jsNumber(ev->orientation()) );
262 wev->put( exec,
"buttons", KJS::jsNumber(ev->buttons()) );
267 KJS::JSObject *
convertEvent( KJS::ExecState * exec,
const QDropEvent * ev)
269 KJS::JSObject *dev =
convertEvent( exec, (QEvent *)ev );
272 dev->put( exec,
"dropAction", KJS::jsNumber( (
int)(ev->dropAction()) ) );
273 dev->put( exec,
"keyboardModifiers", KJS::jsNumber( (
int)(ev->keyboardModifiers()) ) );
274 dev->put( exec,
"possibleActions", KJS::jsNumber( (
int)(ev->possibleActions()) ) );
275 dev->put( exec,
"proposedAction", KJS::jsNumber( (
int)(ev->proposedAction()) ) );
279 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QDragMoveEvent *ev)
281 KJS::JSObject *mev =
convertEvent(exec, (QDropEvent *)ev );
282 mev->put( exec,
"answerRect",
convertToValue( exec, ev->answerRect() ) );
286 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QTimerEvent *ev)
288 KJS::JSObject *dev =
convertEvent( exec, (QEvent *)ev );
289 dev->put( exec,
"timerId", KJS::jsNumber(ev->timerId()) );
293 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QContextMenuEvent *ev)
295 KJS::JSObject *cxev =
convertEvent( exec, (QInputEvent *)ev );
296 cxev->put( exec,
"x", KJS::jsNumber(ev->x()) );
297 cxev->put( exec,
"y", KJS::jsNumber(ev->y()) );
298 cxev->put( exec,
"globalX", KJS::jsNumber(ev->globalX()) );
299 cxev->put( exec,
"globalY", KJS::jsNumber(ev->globalY()) );
301 cxev->put( exec,
"globalPos",
convertToValue( exec, ev->globalPos() ) );
302 cxev->put( exec,
"reason", KJS::jsNumber((
int)ev->reason()) );
306 KJS::JSObject *
convertEvent( KJS::ExecState *exec,
const QFocusEvent *ev)
308 KJS::JSObject *dev =
convertEvent( exec, (QEvent *)ev );
309 dev->put( exec,
"gotFocus", KJS::jsBoolean( ev->gotFocus() ) );
310 dev->put( exec,
"lostFocus", KJS::jsBoolean( ev->lostFocus() ));
312 dev->put( exec,
"reason", KJS::jsNumber((
int) const_cast<QFocusEvent*>( ev )->reason() ) );
KJS::JSObject * event(KJS::ExecState *exec, const QEvent *ev)
KJS::JSObject * convertEvent(KJS::ExecState *exec, const QEvent *ev)
KJS::JSCell * jsString(const QString &s)
KJSEMBED_EXPORT KJS::JSValue * convertToValue(KJS::ExecState *exec, const QVariant &value)
Convert a QVariant to a KJS::JSValue.