Skip to content

Commit 4ea893e

Browse files
committed
Added keyPress and keyRelease in GNEDialog. Refs #16790
1 parent 2c032c1 commit 4ea893e

File tree

2 files changed

+40
-13
lines changed

2 files changed

+40
-13
lines changed

src/netedit/dialogs/GNEDialog.cpp

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@
2929
// ===========================================================================
3030

3131
FXDEFMAP(GNEDialog) MFXDialogBoxMap[] = {
32-
FXMAPFUNC(SEL_COMMAND, MID_GNE_BUTTON_ACCEPT, GNEDialog::onCmdAccept),
33-
FXMAPFUNC(SEL_COMMAND, MID_GNE_BUTTON_CANCEL, GNEDialog::onCmdCancel),
34-
FXMAPFUNC(SEL_COMMAND, MID_GNE_BUTTON_RESET, GNEDialog::onCmdReset),
32+
// interaction
33+
FXMAPFUNC(SEL_KEYPRESS, 0, GNEDialog::onKeyPress),
34+
FXMAPFUNC(SEL_KEYRELEASE, 0, GNEDialog::onKeyRelease),
35+
// buttons
36+
FXMAPFUNC(SEL_COMMAND, MID_GNE_BUTTON_ACCEPT, GNEDialog::onCmdAccept),
37+
FXMAPFUNC(SEL_COMMAND, MID_GNE_BUTTON_CANCEL, GNEDialog::onCmdCancel),
38+
FXMAPFUNC(SEL_COMMAND, MID_GNE_BUTTON_RESET, GNEDialog::onCmdReset),
3539
// abort dialog
3640
FXMAPFUNC(SEL_CLOSE, 0, GNEDialog::onCmdAbort),
3741
FXMAPFUNC(SEL_CHORE, MID_GNE_ABORT, GNEDialog::onCmdAbort),
@@ -147,6 +151,26 @@ GNEDialog::onCmdAbort(FXObject*, FXSelector, void*) {
147151
}
148152

149153

154+
long
155+
GNEDialog::onKeyPress(FXObject* obj, FXSelector sel, void* ptr) {
156+
if (myTesting && (obj != myApplicationWindow->getInternalTest())) {
157+
return 1;
158+
} else {
159+
return FXDialogBox::onKeyPress(obj, sel, ptr);
160+
}
161+
}
162+
163+
164+
long
165+
GNEDialog::onKeyRelease(FXObject* obj, FXSelector sel, void* ptr) {
166+
if (myTesting && (obj != myApplicationWindow->getInternalTest())) {
167+
return 1;
168+
} else {
169+
return FXDialogBox::onKeyRelease(obj, sel, ptr);
170+
}
171+
}
172+
173+
150174
void
151175
GNEDialog::openDialog() {
152176
// create dialog
@@ -155,12 +179,6 @@ GNEDialog::openDialog() {
155179
myFocusButon->setFocus();
156180
// show in the center of app
157181
show(PLACEMENT_OWNER);
158-
// continue depending of open type
159-
if (myOpenType == OpenType::MODAL) {
160-
// run modal dialog
161-
getApp()->runModalFor(this);
162-
}
163-
/*
164182
// continue depending on whether we are testing or not
165183
if (myApplicationWindow->getInternalTest()) {
166184
myTesting = true;
@@ -175,16 +193,19 @@ GNEDialog::openDialog() {
175193
}
176194
} else {
177195
myTesting = false;
178-
getApp()->runModalFor(this);
196+
// continue depending on the dialog type
197+
if (myOpenType == OpenType::MODAL) {
198+
// run modal dialog
199+
getApp()->runModalFor(this);
200+
}
179201
}
180-
*/
181202
}
182203

183204

184205
long
185206
GNEDialog::closeDialogAccepting() {
186207
// check if stopping modal dialog
187-
if (myOpenType == OpenType::MODAL) {
208+
if (!myTesting && (myOpenType == OpenType::MODAL)) {
188209
getApp()->stopModal(this, TRUE);
189210
}
190211
// hide dialog
@@ -198,7 +219,7 @@ GNEDialog::closeDialogAccepting() {
198219
long
199220
GNEDialog::closeDialogCanceling() {
200221
// check if stopping modal dialog
201-
if (myOpenType == OpenType::MODAL) {
222+
if (!myTesting && (myOpenType == OpenType::MODAL)) {
202223
getApp()->stopModal(this, TRUE);
203224
}
204225
// hide dialog

src/netedit/dialogs/GNEDialog.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ class GNEDialog : public FXDialogBox {
114114
/// @brief called when abort is called (either closing dialog or pressing abort button)
115115
long onCmdAbort(FXObject*, FXSelector, void*);
116116

117+
/// @brief called when user presses a key on the dialog
118+
long onKeyPress(FXObject* obj, FXSelector sel, void* ptr);
119+
120+
/// @brief called when user releases a key on the dialog
121+
long onKeyRelease(FXObject* obj, FXSelector sel, void* ptr);
122+
117123
/// @}
118124

119125
protected:

0 commit comments

Comments
 (0)