Keyboard only wxFileDialog
-
- Earned some good credits
- Posts: 119
- Joined: Wed May 19, 2021 11:17 pm
- Contact:
Keyboard only wxFileDialog
I'm trying to make a new dialog that takes all input from the keyboard and not the mouse.
I'm taking the wxFileDialog class as an example and trying to make a keyboard only version.
The problem I'm facing is I can't intercept key events in a wxDialog.
So I can't subclass from a wxDialog but have to go to wxWindow,
in order to be able to process key events.
Which means I can't make it modal (like wxFileDialog).
Also, after the dialog has been used to select a file, and it has been closed,
I have to push the filename to the frame that contains it
instead of the frame pulling the info from the dialog in wxFileDialog.
Am I missing something here?
I'm taking the wxFileDialog class as an example and trying to make a keyboard only version.
The problem I'm facing is I can't intercept key events in a wxDialog.
So I can't subclass from a wxDialog but have to go to wxWindow,
in order to be able to process key events.
Which means I can't make it modal (like wxFileDialog).
Also, after the dialog has been used to select a file, and it has been closed,
I have to push the filename to the frame that contains it
instead of the frame pulling the info from the dialog in wxFileDialog.
Am I missing something here?
Re: Keyboard only wxFileDialog
That doesn't make any sense. Why shouldn't it be possible to process key events in an dialog? What exactly did you try?The problem I'm facing is I can't intercept key events in a wxDialog.
So I can't subclass from a wxDialog but have to go to wxWindow,
in order to be able to process key events.
Besides, usually every GUI is automatically keyboard accessible through the underlying OS (using TAB to cycle through control focus). What are you missing?
Use the source, Luke!
-
- Earned some good credits
- Posts: 119
- Joined: Wed May 19, 2021 11:17 pm
- Contact:
Re: Keyboard only wxFileDialog
I tried to create an event table in my wxDialog subclass
which intercepted paint and keydown messages.
The paint messages were coming through fine
but I was not getting any keydown messages.
Then I switched to wxWindow and this problem went away.
Since a dialog does special processing for certain keys such as escape,
I got the impression that it does not allow it's core keyboard event handling to be bypassed
and hence does not allow subclasses to intercept key events.
The docs about which events are sent by the wxDialog and wxWindow
also seem to suggest this.
It wasn't clear so I just went with what I know works.
which intercepted paint and keydown messages.
The paint messages were coming through fine
but I was not getting any keydown messages.
Then I switched to wxWindow and this problem went away.
Since a dialog does special processing for certain keys such as escape,
I got the impression that it does not allow it's core keyboard event handling to be bypassed
and hence does not allow subclasses to intercept key events.
The docs about which events are sent by the wxDialog and wxWindow
also seem to suggest this.
It wasn't clear so I just went with what I know works.
Re: Keyboard only wxFileDialog
Hi,
Which controls do you have on the dialog?
How do you bind the key event?
Can you show some code?
Also - are you using a wxPanel as a parent of the control or wxDialog?
Thank you.
Which controls do you have on the dialog?
How do you bind the key event?
Can you show some code?
Also - are you using a wxPanel as a parent of the control or wxDialog?
Thank you.
Re: Keyboard only wxFileDialog
A wxDialog is a toplevel window, and therefore a very different thing compared to a wxWindow, so one normally can't replace the other.
Be aware that most key events don't propagate, only the control that has keyboard focus will receive the event. The only exception is wxEVT_CHAR_HOOK. Read the documentation for wxKeyEvent about that option. https://docs.wxwidgets.org/trunk/classwx_key_event.html
Be aware that most key events don't propagate, only the control that has keyboard focus will receive the event. The only exception is wxEVT_CHAR_HOOK. Read the documentation for wxKeyEvent about that option. https://docs.wxwidgets.org/trunk/classwx_key_event.html
Use the source, Luke!
-
- Earned some good credits
- Posts: 119
- Joined: Wed May 19, 2021 11:17 pm
- Contact:
Re: Keyboard only wxFileDialog
I'll explore wxEVT_CHAR_HOOK. That might work. Thanks!doublemax wrote: ↑Fri Aug 27, 2021 3:48 pm A wxDialog is a toplevel window, and therefore a very different thing compared to a wxWindow, so one normally can't replace the other.
Be aware that most key events don't propagate, only the control that has keyboard focus will receive the event. The only exception is wxEVT_CHAR_HOOK. Read the documentation for wxKeyEvent about that option. https://docs.wxwidgets.org/trunk/classwx_key_event.html
-
- Earned some good credits
- Posts: 119
- Joined: Wed May 19, 2021 11:17 pm
- Contact:
Re: Keyboard only wxFileDialog
I don't have any controls on the dialog.
I'm trying to do this:
Code: Select all
class HexDlg : public wxDialog
{
public:
HexDlg( MyFrame *parent, float fScrnDiag );
void OnPaint(wxPaintEvent &event);
void OnKeyDown(wxKeyEvent &event);
void Close();
wxString m_strFileName;
private:
MyFrame *m_owner;
wxDECLARE_EVENT_TABLE();
};
wxBEGIN_EVENT_TABLE(HexDlg, wxWindow)
EVT_PAINT (HexDlg::OnPaint)
EVT_KEY_DOWN (HexDlg::OnKeyDown)
wxEND_EVENT_TABLE()
-
- Earned some good credits
- Posts: 119
- Joined: Wed May 19, 2021 11:17 pm
- Contact:
Re: Keyboard only wxFileDialog
I tried wxEVT_CHAR_HOOK on a wxDialog, that did not work either.Rohit Agarwal wrote: ↑Fri Aug 27, 2021 4:16 pmI'll explore wxEVT_CHAR_HOOK. That might work. Thanks!doublemax wrote: ↑Fri Aug 27, 2021 3:48 pm A wxDialog is a toplevel window, and therefore a very different thing compared to a wxWindow, so one normally can't replace the other.
Be aware that most key events don't propagate, only the control that has keyboard focus will receive the event. The only exception is wxEVT_CHAR_HOOK. Read the documentation for wxKeyEvent about that option. https://docs.wxwidgets.org/trunk/classwx_key_event.html
It does work on a wxWindow.
So I guess you can't create your own keyboard event handling mechanism on a wxDialog.
Is it possible to make a wxWindow modal? I guess it is not.
- doublemax@work
- Super wx Problem Solver
- Posts: 474
- Joined: Wed Jul 29, 2020 6:06 pm
- Location: NRW, Germany
Re: Keyboard only wxFileDialog
Try adding a wxPanel to the dialog, and call SetFocus() on it in the dialog constructor.
-
- Earned some good credits
- Posts: 119
- Joined: Wed May 19, 2021 11:17 pm
- Contact:
Re: Keyboard only wxFileDialog
Thanks.
I'll try that. I think it will work for my purposes.
I'll try that. I think it will work for my purposes.
-
- Earned some good credits
- Posts: 119
- Joined: Wed May 19, 2021 11:17 pm
- Contact:
Re: Keyboard only wxFileDialog
Hi.
I'm in the process of making a toolkit for extending wxWidgets
with the ability to design "Modal" UIs which can be completely keyboard-based
and do not require any mouse input.
I've created a modal app using wxWidgets and this toolkit called ModalWX.
If you Google ModalWX, you will find it.
https://github.com/Rohit-Agarwal-Khitchdee/Modal
At present this app only demonstrates it's ability to navigate a Modal codebase.
I'm looking for early feedback on the usability of these features.
ModalWX is licensed under the MIT licence so it's open source.
Since this component is intended for wx developers, I'm posting here to get early feedback.
I'm in the process of making a toolkit for extending wxWidgets
with the ability to design "Modal" UIs which can be completely keyboard-based
and do not require any mouse input.
I've created a modal app using wxWidgets and this toolkit called ModalWX.
If you Google ModalWX, you will find it.
https://github.com/Rohit-Agarwal-Khitchdee/Modal
At present this app only demonstrates it's ability to navigate a Modal codebase.
I'm looking for early feedback on the usability of these features.
ModalWX is licensed under the MIT licence so it's open source.
Since this component is intended for wx developers, I'm posting here to get early feedback.
Re: Keyboard only wxFileDialog
Hi,
What would be the purpose?
Something like this should make the life of developer easier not harder. And mouse makes it so.
Is there any machine now in the XXI century that doesn't have a mouse?
Even blind people use mouse from time to time. (No offense)
Thank you.
What would be the purpose?
Something like this should make the life of developer easier not harder. And mouse makes it so.
Is there any machine now in the XXI century that doesn't have a mouse?
Even blind people use mouse from time to time. (No offense)
Thank you.
-
- Earned some good credits
- Posts: 119
- Joined: Wed May 19, 2021 11:17 pm
- Contact:
Re: Keyboard only wxFileDialog
The purpose of this posting is to demonstrate
that in the context of source-code navigation inside an IDE
something which we all have to do,
a Modal, kybd-only approach is a lot more efficient than a WIMP, mouse-based one.
If you build ModalWX.cpp, (using the same settings as the minimal sample),
It's just a code navigation demo that navigates itself using a Modal UI approach
and demonstrates the efficiency advantage that I'm claiming.
that in the context of source-code navigation inside an IDE
something which we all have to do,
a Modal, kybd-only approach is a lot more efficient than a WIMP, mouse-based one.
If you build ModalWX.cpp, (using the same settings as the minimal sample),
It's just a code navigation demo that navigates itself using a Modal UI approach
and demonstrates the efficiency advantage that I'm claiming.