PDA

View Full Version : Shortcut Context Problem



dvmorris
9th July 2007, 23:14
When I hit "save as" in my program on OS X, and I try to type a file name with numbers in it, instead of typing the numbers in the textbox, it executes the associated shortcut in my program behing the "save as" dialog box.

Does that make sense? I have a series of qactions inside qmenu's that have "1" "2" "3" etc... as shortcuts, and the save as and open file dialogs won't let me type those numbers.

I am using the qshortcutmanager class from the edyuk source code, but I don't really think it is causing this problem. I tried setting each qaction's shortcut context to Qt::WidgetContext, but that didn't seem to solve the problem. I have no idea what else to try.

Thanks for the help,

dave

jpn
10th July 2007, 06:35
Is the file dialog modeless? Perhaps you could make it modal?

dvmorris
10th July 2007, 11:52
oh I didn't think about that. The file dialog on OS X is opening as a drawer by default. I just tried on Windows and the problem doesn't occur. I guess I can just add a Mac specific flag to make the dialog open differently.

I also notice though, that inside a floating or docked QDockWidget that contains a QTextEdit and a QLineEdit, typing in it causes the shortcuts to highlight in the menu bar but not actually execute. I'm not sure if there is a way to make that not happen, because it is kind of distracting. The text edit box is a script editor for the program and the flashing menu bar is really distracting while the user is typing script commands.

thanks for your help,
dave

Gopala Krishna
10th July 2007, 14:16
I am afraid this problem will haunt me too since i had same problem with exception being the text was being typed in QGraphicsTextItem. The corresponding thread is here (http://www.qtcentre.org/forum/f-qt-programming-2/t-qgraphicstextitem-focus-problem-7719.html).

The solution for that was to simply implement an event filter which worked for me.
But now it looks like an event filter has to be installed to QApplication each and every time an edit control gets focus.
Is there anything that can be done globally to change this behaviour ?

dvmorris
10th July 2007, 22:39
I have no idea if there is a global solution to this problem, but it strikes me as extremely odd that no one else has problems like this. This is a pretty common thing to do in an application, so it seems like there should be an easier way around this. The shortcutcontext thing was the obvious solution to me, but that didn't work at all. That's really strange.

Thanks for your help, though, I guess I'll try out the event filter thing.