diff --git a/advotracker/src/callbacks/global_state.rs b/advotracker/src/callbacks/global_state.rs index d0139ad..65494c8 100644 --- a/advotracker/src/callbacks/global_state.rs +++ b/advotracker/src/callbacks/global_state.rs @@ -23,33 +23,19 @@ struct Environment { rust_log: String, } -/// Provides generic methods to handle states of datatypes (e.g. used in `PolicyList`). +/// Provides generic methods to handle states of datatypes (e.g. used in `PolicyCheckState`). pub trait GlobalState { - /// Navigates to the given entity. - fn navigate(&self, to: Entity, ctx: &mut Context<'_>) { - if let Some(old_focused_element) = ctx.window().get::("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").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 { - let mut widget = ctx.get_widget(entity); - - let entry = widget.get_mut::("text"); - if entry.is_empty() { - return None; - } - - let copy = entry.to_string(); - entry.clear(); - Some(copy) - } + // /// Navigates to the given entity. + // fn navigate(&self, to: Entity, ctx: &mut Context<'_>) { + // if let Some(old_focused_element) = ctx.window().get::("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").focused_widget = None; + // 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. diff --git a/advotracker/src/callbacks/policycheck_state.rs b/advotracker/src/callbacks/policycheck_state.rs index c19b3b0..35e3bf8 100644 --- a/advotracker/src/callbacks/policycheck_state.rs +++ b/advotracker/src/callbacks/policycheck_state.rs @@ -63,7 +63,7 @@ pub struct PolicyCheckState { duration: Duration, label_result: Entity, lang: String, - last_focused: Option, + //last_focused: Option, button_menu: Entity, menu: Entity, policy_data_count: u64, @@ -144,10 +144,10 @@ impl PolicyCheckState { match envy::from_env::() { Ok(environment) => { if environment.test_lang != lang { lang = environment.test_lang; } - trace!(target: "advotracker", lang = ?lang); }, Err(e) => { info!(target: "advotracker", "{}", e) } } + trace!(target: "advotracker", lang = ?lang); lang } @@ -472,15 +472,15 @@ impl State for PolicyCheckState { /// Update the widget state. fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) { - // clear focus on focus moved - if self.last_focused != ctx.window().get::("global").focused_widget { - if let Some(last_focused) = self.last_focused { - ctx.get_widget(last_focused).set("focused", false); - // widget is unvisible, but takes space to be considered - ctx.get_widget(last_focused) - .set("visibility", Visibility::Collapsed); - } - } + // // clear focus on focus moved + // if self.last_focused != ctx.window().get::("global").focused_widget { + // if let Some(last_focused) = self.last_focused { + // ctx.get_widget(last_focused).set("focused", false); + // // widget is unvisible, but takes space to be considered + // ctx.get_widget(last_focused) + // .set("visibility", Visibility::Collapsed); + // } + //} if let Some(action) = self.action { match action {