@effindomv2/fui-rs 0.1.22 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +1 -1
- package/package.json +1 -1
- package/src/node/core.rs +11 -0
- package/src/node/custom_drawable.rs +20 -0
package/Cargo.toml
CHANGED
package/package.json
CHANGED
package/src/node/core.rs
CHANGED
|
@@ -1808,6 +1808,17 @@ pub trait Node: Clone {
|
|
|
1808
1808
|
self
|
|
1809
1809
|
}
|
|
1810
1810
|
|
|
1811
|
+
fn focus_now(&self) -> &Self
|
|
1812
|
+
where
|
|
1813
|
+
Self: Sized,
|
|
1814
|
+
{
|
|
1815
|
+
let handle = self.node_ref().handle();
|
|
1816
|
+
if handle != NodeHandle::INVALID {
|
|
1817
|
+
ui::request_focus(handle.raw());
|
|
1818
|
+
}
|
|
1819
|
+
self
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1811
1822
|
fn on_key_down(&self, handler: impl Fn(&mut KeyEventArgs) + 'static) -> &Self
|
|
1812
1823
|
where
|
|
1813
1824
|
Self: Sized,
|
|
@@ -121,6 +121,8 @@ impl ThemeBindable for CustomDrawable {
|
|
|
121
121
|
#[cfg(test)]
|
|
122
122
|
mod tests {
|
|
123
123
|
use super::*;
|
|
124
|
+
use crate::app::Application;
|
|
125
|
+
use crate::ffi::{self, Call};
|
|
124
126
|
|
|
125
127
|
fn assert_flex_box_surface<T: FlexBoxSurface>() {}
|
|
126
128
|
fn assert_theme_bindable<T: ThemeBindable>() {}
|
|
@@ -145,4 +147,22 @@ mod tests {
|
|
|
145
147
|
drop(drawable);
|
|
146
148
|
invalidator.mark_dirty();
|
|
147
149
|
}
|
|
150
|
+
|
|
151
|
+
#[test]
|
|
152
|
+
fn custom_drawable_requests_focus_through_node_trait() {
|
|
153
|
+
ffi::test::reset();
|
|
154
|
+
let drawable = CustomDrawable::new(|_| {});
|
|
155
|
+
drawable.focusable(true, 0);
|
|
156
|
+
Application::mount(drawable.clone());
|
|
157
|
+
let handle = drawable.handle().raw();
|
|
158
|
+
ffi::test::take_calls();
|
|
159
|
+
|
|
160
|
+
drawable.focus_now();
|
|
161
|
+
|
|
162
|
+
let calls = ffi::test::take_calls();
|
|
163
|
+
assert!(calls.iter().any(
|
|
164
|
+
|call| matches!(call, Call::RequestFocus { handle: requested } if *requested == handle)
|
|
165
|
+
));
|
|
166
|
+
Application::unmount();
|
|
167
|
+
}
|
|
148
168
|
}
|