DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR Pending]
Link: http://www.fltk.org/str.php?L2562
Version: 1.3-feature
Fix Version: 1.3.0 (r8417)
Hmm, that's indeed another use case than I thought, and that I use in my
own app with a similar patch for FLTK 1.1. I really thought of a more
specific title for each dialog than only the application name...
One way to solve both aspects (and keep the empty default as-is), would be
to add another function like fl_message_title_default(). In this case you
could set a specific (single-shot) title for one dialog, while having
another default title for all other dialogs (default = empty).
Anyway, I'd like to find a solution soon, and the next snapshot will be in
6 days from now (on Friday). I hope that you can test earlier, and for your
convenience I add the patch file "fl_ask-r8411-r8417.diff" to this posting,
which is the relevant diff against the latest snapshot. You can also always
find the current files in subversion relative to this URL:
http://svn.easysw.com/public/fltk/fltk/branches/branch-1.3/
Thanks for your feedback.
Link: http://www.fltk.org/str.php?L2562
Version: 1.3-feature
Fix Version: 1.3.0 (r8417)
Index: src/fl_ask.cxx
===================================================================
--- src/fl_ask.cxx (Revision 8411)
+++ src/fl_ask.cxx (Revision 8417)
@@ -56,6 +56,7 @@
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 @@
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 @@
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
@@ -242,6 +244,7 @@
if (g) // regrab the previous popup menu, if there was one
Fl::grab(g);
icon->label(prev_icon_label);
+ message_form->label(0); // reset window title
avoidRecursion = 0;
return ret_val;
@@ -290,7 +293,7 @@
break;
default :
break;
- }
+ }
#else
switch (type) {
case FL_BEEP_DEFAULT :
@@ -408,11 +411,11 @@
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/fl_ask.H>
-*/
+*/
Fl_Widget *fl_message_icon() {makeform(); return icon;}
static const char* input_innards(const char* fmt, va_list ap,
@@ -479,6 +482,53 @@
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 <FL/fl_ask.H>
+ \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 <FL/fl_ask.H>
+ \return 0 if disable, non-zero otherwise
+ \see fl_message_hotspot(int)
+ */
+int fl_message_hotspot(void) {
+ return enableHotspot;
+}
+
+/** Sets the title of the dialog window used in many common dialogs.
+
+ This window \p title will be used in the next call of one of the
+ common dialogs like fl_message(), fl_alert(), fl_ask(), fl_choice(),
+ fl_input(), fl_password().
+
+ The \p title string is copied internally, so that you can use a
+ local variable or free the string immediately after this call. It
+ applies only to the \b next call of one of the common dialogs and
+ will be reset to an empty title (the default for all dialogs) after
+ that call.
+
+ \note \#include <FL/fl_ask.H>
+ \param[in] title window label, string copied internally
+*/
+void fl_message_title(const char *title) {
+ makeform();
+ message_form->copy_label(title);
+}
+
/** @} */
//
Index: FL/fl_ask.H
===================================================================
--- FL/fl_ask.H (Revision 8411)
+++ FL/fl_ask.H (Revision 8417)
@@ -3,7 +3,7 @@
//
// Standard dialog header file for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2011 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -64,6 +64,11 @@
inline void fl_message_font(Fl_Font f, Fl_Fontsize s) {
fl_message_font_ = f; fl_message_size_ = s;}
+FL_EXPORT void fl_message_hotspot(int enable);
+FL_EXPORT int fl_message_hotspot(void);
+
+FL_EXPORT void fl_message_title(const char *title);
+
// pointers you can use to change FLTK to a foreign language:
extern FL_EXPORT const char* fl_no;
extern FL_EXPORT const char* fl_yes;
Index: test/ask.cxx
===================================================================
--- test/ask.cxx (Revision 8411)
+++ test/ask.cxx (Revision 8417)
@@ -61,8 +61,12 @@
}
void window_callback(Fl_Widget*, void*) {
+ int hotspot = fl_message_hotspot();
+ fl_message_hotspot(0);
+ fl_message_title("note: no hotspot set for this dialog");
int rep = fl_choice("Are you sure you want to quit?",
"Cancel", "Quit", "Dunno");
+ fl_message_hotspot(hotspot);
if (rep==1)
exit(0);
else if (rep==2)
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev