widget:global_state: activate navigate() method
* allow widgets to nagivate to other widget context Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -49,24 +49,32 @@ pub trait GlobalState {
|
||||
lang
|
||||
}
|
||||
|
||||
// /// Navigates to the given entity.
|
||||
// fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
|
||||
// if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
|
||||
// let mut old_focused_element = ctx.get_widget(old_focused_element);
|
||||
// old_focused_element.set("focused", false);
|
||||
// //old_focused_element.update_theme_by_state(false);
|
||||
// }
|
||||
// ctx.window().get_mut::<Global>("global").focused_widget = None;
|
||||
// ctx.widget().set("visibility", Visibility::Collapsed);
|
||||
// ctx.get_widget(to).set("visibility", Visibility::Visible);
|
||||
// }
|
||||
/// Get the text of a widget.
|
||||
fn get_text(&self, ctx: &mut Context<'_>, entity: Entity) -> Option<String> {
|
||||
let text = TextBox::text_clone(&ctx.get_widget(entity));
|
||||
|
||||
if text.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
TextBox::text_set(&mut ctx.get_widget(entity), String::default());
|
||||
Some(text)
|
||||
}
|
||||
|
||||
/// Navigates to the given entity.
|
||||
fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
|
||||
if let Some(old_focused_element) = *Window::focus_state_ref(&ctx.window()).focused_entity() {
|
||||
ctx.push_event_by_window(FocusEvent::RemoveFocus(old_focused_element));
|
||||
}
|
||||
ctx.widget().set("visibility", Visibility::Collapsed);
|
||||
ctx.get_widget(to).set("visibility", Visibility::Visible);
|
||||
}
|
||||
|
||||
/// Save the our data structure and convert it to `ron` file format.
|
||||
/// The cargo package identifier (here: 'nwx.advotracker') is taken to create the app directory.
|
||||
/// in users 'settings directory'. The directory location is OS dependant
|
||||
/// (Windows: AppData, Unix: XDG_CONFIG_HOME, MacOS: $HOME/Library/Preferences).
|
||||
/// The data is stored in filename PROP_ADVOTRACKER (here: `advotracker.ron`)
|
||||
|
||||
fn save(&self, registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||
registry
|
||||
.get::<Settings>("settings")
|
||||
|
||||
Reference in New Issue
Block a user