mirror of
https://github.com/fltk/fltk.git
synced 2026-05-31 22:04:26 +08:00
Fix keyboard Up and Down for Fl_Hold_Browser (#1403)
This commit is contained in:
+18
-6
@@ -711,25 +711,37 @@ int Fl_Browser_::handle(int event) {
|
|||||||
// must do shortcuts first or the scrollbar will get them...
|
// must do shortcuts first or the scrollbar will get them...
|
||||||
if (event == FL_ENTER || event == FL_LEAVE) return 1;
|
if (event == FL_ENTER || event == FL_LEAVE) return 1;
|
||||||
if (event == FL_KEYBOARD && type() >= FL_HOLD_BROWSER) {
|
if (event == FL_KEYBOARD && type() >= FL_HOLD_BROWSER) {
|
||||||
void* l1 = selection_;
|
void* l = selection_;
|
||||||
void* l = l1; if (!l) l = top_; if (!l) l = item_first();
|
if (!l)
|
||||||
|
l = top_;
|
||||||
|
if (!l)
|
||||||
|
l = item_first();
|
||||||
if (l) {
|
if (l) {
|
||||||
if (type()==FL_HOLD_BROWSER) {
|
if (type()==FL_HOLD_BROWSER) {
|
||||||
switch (Fl::event_key()) {
|
switch (Fl::event_key()) {
|
||||||
case FL_Down:
|
case FL_Down:
|
||||||
while ((l = item_next(l))) {
|
if (selection_)
|
||||||
|
l = item_next(selection_);
|
||||||
|
while (l) {
|
||||||
if (item_height(l)>0) {
|
if (item_height(l)>0) {
|
||||||
select_only(l, when() & ~FL_WHEN_NOT_CHANGED);
|
select_only(l, when() & ~FL_WHEN_NOT_CHANGED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
l = item_next(l);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
case FL_Up:
|
case FL_Up:
|
||||||
while ((l = item_prev(l))) {
|
l = nullptr; // Preselected item is useless here
|
||||||
|
if (selection_)
|
||||||
|
l = item_prev(selection_);
|
||||||
|
if (!l)
|
||||||
|
l = item_last();
|
||||||
|
while (l) {
|
||||||
if (item_height(l)>0) {
|
if (item_height(l)>0) {
|
||||||
select_only(l, when() & ~FL_WHEN_NOT_CHANGED);
|
select_only(l, when() & ~FL_WHEN_NOT_CHANGED);
|
||||||
break; // no need to test wp (return 1)
|
break; // no need to test wp (return 1)
|
||||||
}
|
}
|
||||||
|
l = item_prev(l);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -751,7 +763,7 @@ int Fl_Browser_::handle(int event) {
|
|||||||
case FL_Down:
|
case FL_Down:
|
||||||
while ((l = item_next(l))) {
|
while ((l = item_next(l))) {
|
||||||
if (Fl::event_state(FL_SHIFT|FL_CTRL))
|
if (Fl::event_state(FL_SHIFT|FL_CTRL))
|
||||||
select(l, l1 ? item_selected(l1) : 1, when());
|
select(l, selection_ ? item_selected(selection_) : 1, when());
|
||||||
if (wp.deleted()) return 1;
|
if (wp.deleted()) return 1;
|
||||||
if (item_height(l)>0) goto J1;
|
if (item_height(l)>0) goto J1;
|
||||||
}
|
}
|
||||||
@@ -759,7 +771,7 @@ int Fl_Browser_::handle(int event) {
|
|||||||
case FL_Up:
|
case FL_Up:
|
||||||
while ((l = item_prev(l))) {
|
while ((l = item_prev(l))) {
|
||||||
if (Fl::event_state(FL_SHIFT|FL_CTRL))
|
if (Fl::event_state(FL_SHIFT|FL_CTRL))
|
||||||
select(l, l1 ? item_selected(l1) : 1, when());
|
select(l, selection_ ? item_selected(selection_) : 1, when());
|
||||||
if (wp.deleted()) return 1;
|
if (wp.deleted()) return 1;
|
||||||
if (item_height(l)>0) goto J1;
|
if (item_height(l)>0) goto J1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user