Author: matt
Date: 2007-11-19 08:21:19 -0800 (Mon, 19 Nov 2007)
New Revision: 5981
Log:
STR 1745: in fl_ask, if the rightmost button has a shortcut in its label, the
default 'Escape' is overridden.
Modified:
branches/branch-1.1/src/Fl_Pack.cxx
branches/branch-1.1/src/fl_ask.cxx
branches/branch-1.1/src/fl_shortcut.cxx
Modified: branches/branch-1.1/src/Fl_Pack.cxx
===================================================================
--- branches/branch-1.1/src/Fl_Pack.cxx 2007-11-19 15:49:51 UTC (rev 5980)
+++ branches/branch-1.1/src/Fl_Pack.cxx 2007-11-19 16:21:19 UTC (rev 5981)
@@ -54,20 +54,20 @@
if (horizontal()) {
rw = -spacing_;
rh = th;
-
+
for (int i = children(); i--;)
if (child(i)->visible()) {
- if (child(i) != this->resizable()) rw += child(i)->w();
- rw += spacing_;
+ if (child(i) != this->resizable()) rw += child(i)->w();
+ rw += spacing_;
}
} else {
rw = tw;
rh = -spacing_;
-
+
for (int i = children(); i--;)
if (child(i)->visible()) {
- if (child(i) != this->resizable()) rh += child(i)->h();
- rh += spacing_;
+ if (child(i) != this->resizable()) rh += child(i)->h();
+ rh += spacing_;
}
}
for (int i = children(); i--;) {
@@ -87,18 +87,18 @@
}
// Last child, if resizable, takes all remaining room
if(i == 0 && o == this->resizable()) {
- if(horizontal())
- W = tw - rw;
- else
- H = th - rh;
+ if(horizontal())
+ W = tw - rw;
+ else
+ H = th - rh;
}
if (spacing_ && current_position>maximum_position && box() &&
- (X != o->x() || Y != o->y() || d&FL_DAMAGE_ALL)) {
+ (X != o->x() || Y != o->y() || d&FL_DAMAGE_ALL)) {
fl_color(color());
if (horizontal())
- fl_rectf(maximum_position, ty, spacing_, th);
+ fl_rectf(maximum_position, ty, spacing_, th);
else
- fl_rectf(tx, maximum_position, tw, spacing_);
+ fl_rectf(tx, maximum_position, tw, spacing_);
}
if (X != o->x() || Y != o->y() || W != o->w() || H != o->h()) {
o->resize(X,Y,W,H);
@@ -115,7 +115,7 @@
current_position += spacing_;
}
}
-
+
if (horizontal()) {
if (maximum_position < tx+tw && box()) {
fl_color(color());
@@ -129,7 +129,7 @@
}
th = maximum_position-ty;
}
-
+
tw += Fl::box_dw(box()); if (tw <= 0) tw = 1;
th += Fl::box_dh(box()); if (th <= 0) th = 1;
if (tw != w() || th != h()) {
Modified: branches/branch-1.1/src/fl_ask.cxx
===================================================================
--- branches/branch-1.1/src/fl_ask.cxx 2007-11-19 15:49:51 UTC (rev 5980)
+++ branches/branch-1.1/src/fl_ask.cxx 2007-11-19 16:21:19 UTC (rev 5981)
@@ -202,6 +202,11 @@
if (button[1]->visible() && !input->visible())
button[1]->take_focus();
message_form->hotspot(button[0]);
+ if (b0 && Fl_Widget::label_shortcut(b0))
+ button[0]->shortcut(0);
+ else
+ button[0]->shortcut(FL_Escape);
+
message_form->show();
int r;
for (;;) {
Modified: branches/branch-1.1/src/fl_shortcut.cxx
===================================================================
--- branches/branch-1.1/src/fl_shortcut.cxx 2007-11-19 15:49:51 UTC (rev
5980)
+++ branches/branch-1.1/src/fl_shortcut.cxx 2007-11-19 16:21:19 UTC (rev
5981)
@@ -207,19 +207,28 @@
// Tests for &x shortcuts in button labels:
-int Fl_Widget::test_shortcut(const char *l) {
- char c = Fl::event_text()[0];
- if (!c || !l) return 0;
+char Fl_Widget::label_shortcut(const char *t) {
+ if (!t) return 0;
for (;;) {
- if (!*l) return 0;
- if (*l++ == '&' && *l) {
- if (*l == '&') l++;
- else if (*l == c) return 1;
- else return 0;
+ if (*t==0) return 0;
+ if (*t=='&') {
+ char s = t[1];
+ if (s==0) return 0;
+ else if (s=='&') t++;
+ else return s;
}
+ t++;
}
}
+int Fl_Widget::test_shortcut(const char *t) {
+ char c = Fl::event_text()[0];
+ if (!c || !t) return 0;
+ if (c == label_shortcut(t))
+ return 1;
+ return 0;
+}
+
int Fl_Widget::test_shortcut() {
if (!(flags()&SHORTCUT_LABEL)) return 0;
return test_shortcut(label());
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit