From f8c0dd01101139c7b79e02d33c2e7dad5219056c Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sat, 12 Feb 2011 11:31:40 +0000 Subject: Hotspot behavior of fl_message() and other common dialogs is now optional (STR #2561). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8415 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/fl_ask.cxx | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/fl_ask.cxx b/src/fl_ask.cxx index e01b25845..b6e065daa 100644 --- a/src/fl_ask.cxx +++ b/src/fl_ask.cxx @@ -56,6 +56,7 @@ static int ret_val; static const char *iconlabel = "?"; Fl_Font fl_message_font_ = FL_HELVETICA; Fl_Fontsize fl_message_size_ = -1; +static int enableHotspot = 1; #ifdef __APPLE__ extern "C" void NSBeep(void); #endif @@ -78,7 +79,7 @@ static Fl_Window *makeform() { message_form->size(410,103); return message_form; } - // make sure that the dialog does not become the child of some + // make sure that the dialog does not become the child of some // current group Fl_Group *previously_current_group = Fl_Group::current(); Fl_Group::current(0); @@ -226,9 +227,10 @@ static int innards(const char* fmt, va_list ap, resizeform(); - if (button[1]->visible() && !input->visible()) + if (button[1]->visible() && !input->visible()) button[1]->take_focus(); - message_form->hotspot(button[0]); + if (enableHotspot) + message_form->hotspot(button[0]); if (b0 && Fl_Widget::label_shortcut(b0)) button[0]->shortcut(0); else @@ -290,7 +292,7 @@ void fl_beep(int type) { break; default : break; - } + } #else switch (type) { case FL_BEEP_DEFAULT : @@ -408,11 +410,11 @@ int fl_choice(const char*fmt,const char *b0,const char *b1,const char *b2,...){ va_end(ap); return r; } -/** Gets the Fl_Box icon container of the current default dialog used in - many common dialogs like fl_message(), fl_alert(), - fl_ask(), fl_choice(), fl_input(), fl_password() +/** Gets the Fl_Box icon container of the current default dialog used in + many common dialogs like fl_message(), fl_alert(), + fl_ask(), fl_choice(), fl_input(), fl_password() \note \#include -*/ +*/ Fl_Widget *fl_message_icon() {makeform(); return icon;} static const char* input_innards(const char* fmt, va_list ap, @@ -479,6 +481,33 @@ const char *fl_password(const char *fmt, const char *defstr, ...) { return r; } +/** Sets whether or not to move the common message box used in + many common dialogs like fl_message(), fl_alert(), + fl_ask(), fl_choice(), fl_input(), fl_password() to follow + the mouse pointer. + + The default is \e enabled, so that the default button is the + hotspot and appears at the mouse position. + \note \#include + \param[in] enable non-zero enables hotspot behavior, + 0 disables hotspot + */ +void fl_message_hotspot(int enable) { + enableHotspot = enable ? 1 : 0; +} + +/** Gets whether or not to move the common message box used in + many common dialogs like fl_message(), fl_alert(), + fl_ask(), fl_choice(), fl_input(), fl_password() to follow + the mouse pointer. + \note \#include + \return 0 if disable, non-zero otherwise + \see fl_message_hotspot(int) + */ +int fl_message_hotspot(void) { + return enableHotspot; +} + /** @} */ // -- cgit v1.2.3