window: do not scroll on touch-focus
This commit is contained in:
committed by
Raphael Coeffic
parent
170fa8152e
commit
ff080ff3d8
+13
-2
@@ -134,10 +134,19 @@ static void window_event_cb(lv_event_t * e)
|
|||||||
|
|
||||||
} else if (code == LV_EVENT_FOCUSED) {
|
} else if (code == LV_EVENT_FOCUSED) {
|
||||||
if (inhibit_focus) return;
|
if (inhibit_focus) return;
|
||||||
|
|
||||||
bool focused = ((Window *)target->user_data)->hasFocus();
|
bool focused = ((Window *)target->user_data)->hasFocus();
|
||||||
TRACE_WINDOWS("FOCUSED[%d] %s", focused,
|
TRACE_WINDOWS("FOCUSED[%d] %s", focused,
|
||||||
window->getWindowDebugString().c_str());
|
window->getWindowDebugString().c_str());
|
||||||
if (!focused) { window->setFocus(); }
|
|
||||||
|
if (!focused) {
|
||||||
|
SetFocusFlag flag = SET_FOCUS_DEFAULT;
|
||||||
|
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||||
|
if(indev_type == LV_INDEV_TYPE_POINTER) {
|
||||||
|
flag = SET_FOCUS_NO_SCROLL;
|
||||||
|
}
|
||||||
|
window->setFocus(flag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,7 +392,9 @@ void Window::setFocus(uint8_t flag, Window * from)
|
|||||||
|
|
||||||
// scroll before calling focusHandler so that the window can adjust the
|
// scroll before calling focusHandler so that the window can adjust the
|
||||||
// scroll position if needed
|
// scroll position if needed
|
||||||
lv_obj_scroll_to_view_recursive(lvobj, LV_ANIM_OFF);
|
if (flag != SET_FOCUS_NO_SCROLL) {
|
||||||
|
lv_obj_scroll_to_view_recursive(lvobj, LV_ANIM_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
clearFocus();
|
clearFocus();
|
||||||
focusWindow = this;
|
focusWindow = this;
|
||||||
|
|||||||
+5
-4
@@ -53,10 +53,11 @@ constexpr WindowFlags WINDOW_FLAGS_LAST = PUSH_FRONT;
|
|||||||
|
|
||||||
enum SetFocusFlag
|
enum SetFocusFlag
|
||||||
{
|
{
|
||||||
SET_FOCUS_DEFAULT,
|
SET_FOCUS_DEFAULT = 0,
|
||||||
SET_FOCUS_FORWARD,
|
SET_FOCUS_FORWARD = 1,
|
||||||
SET_FOCUS_BACKWARD,
|
SET_FOCUS_BACKWARD = 2,
|
||||||
SET_FOCUS_FIRST
|
SET_FOCUS_FIRST = 3,
|
||||||
|
SET_FOCUS_NO_SCROLL= 4
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef lv_obj_t *(*LvglCreate)(lv_obj_t *);
|
typedef lv_obj_t *(*LvglCreate)(lv_obj_t *);
|
||||||
|
|||||||
Reference in New Issue
Block a user