C++ Qt Inherit QMessageBox to delay user input in order to prevent unintended action -
problem
windows has system setting cause mouse pointer jump (move) new focus element automatically, e.g. default button of dialog pops up. while advantage increase in speed , reduction of mouse movements, has disadvantage:
if happens when before user clicks on element, user unable abort his/her action in time , accept dialogs default button because focus moved system. may entail cumbersome work retrace steps point (think file chooser dialog forgot long path input previously) mean triggering irreversible process (e.g. file deletion).
aim
essentially disable dialog's inputs small amount of time, enough prevent inadvertant mouse click or keyboard button press.
question
it comes down c++ question, namely how access base classes' objects (gui widgets) inheriting class, i.e.
- disable button widgets of qmessagebox
- start single shot qtimer , connect slot that
- enables disabled widgets
(as alternative, reimplement input event handlers suppress input specific amount of time, although intend keep time short (e.g. 100 ms), user not informed of disabled input using method.)
a simple class derived qdialogbox can found @ http://www.qtforum.org/article/24342/messagebox-auto-close-mouse-event-close.html.
do need use 1 of "native"-ish message boxes provided qmessagebox static functions?
otherwise, that's pretty simple achieve, building qmessagebox , adding standard buttons it:
qmessagebox *messagebox = new qmessagebox; qpushbutton *okbutton = messagebox->addbutton(qmessagebox::ok); okbutton->setenabled(false); // use qtimer add logic reenable button // use qcursor move mouse cursor on button // add nice countdown in button's label, firefox // add other nice ux touches wanted
last points left exercise reader :)
Comments
Post a Comment