slint/examples/todo-mvc/ui/widgets/focus_touch_area.slint
Florian Blasius 0870585c32
Added TodoMVC example (Rust mock version) (#5396)
* Added TodoMVC example (Rust mock version)

* TodoMVC: use visible-width instead of width for selection items

and format

* TodoMVC: layout fix for qt checkbox

* TdodoMVC: fix license issues in the example

* Update examples/todo_mvc/ui/views/task_list_view.slint

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* TdodoMVC: fix license issues in the example

* TodoMVC: code review changes

* TodoMVC: code review changes

* Update .reuse/dep5

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update examples/todo_mvc/rust/src/adapters/navigation_adapter.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update examples/todo_mvc/rust/src/adapters/navigation_adapter.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* TodoMVC: refactor task list model (code review feedback)

* TodoMVC: code review feedback

* Update examples/todo-mvc/rust/src/mvc/controllers/task_list_controller.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* TodoMVC: add missing link in dep5

* dep5 fix

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-06-13 13:05:44 +02:00

53 lines
1.4 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT
export component FocusTouchArea {
in property <bool> enabled: true;
out property <bool> has-focus <=> focus-scope.has-focus;
out property <bool> pressed <=> touch-area.pressed;
out property <bool> has-hover <=> touch-area.has-hover;
out property <bool> enter-pressed;
in property <MouseCursor> mouse-cursor <=> touch-area.mouse-cursor;
callback clicked <=> touch-area.clicked;
forward-focus: focus-scope;
focus-scope := FocusScope {
x: 0;
width: 0px;
enabled: root.enabled;
key-pressed(event) => {
if !root.enabled {
return reject;
}
if (event.text == " " || event.text == "\n") && !root.enter-pressed {
root.enter-pressed = true;
touch-area.clicked();
return accept;
}
reject
}
key-released(event) => {
if !root.enabled {
return reject;
}
if (event.text == " " || event.text == "\n") && root.enter-pressed {
root.enter-pressed = false;
return accept;
}
reject
}
}
touch-area := TouchArea {
enabled: root.enabled;
}
}