feat(segmented_button): add scrollable_focus to toggle focus scrolling
This commit is contained in:
parent
072a3d5ca0
commit
a11cf79b46
1 changed files with 43 additions and 38 deletions
|
|
@ -63,6 +63,8 @@ where
|
||||||
pub(super) id: Option<Id>,
|
pub(super) id: Option<Id>,
|
||||||
/// The icon used for the close button.
|
/// The icon used for the close button.
|
||||||
pub(super) close_icon: Icon,
|
pub(super) close_icon: Icon,
|
||||||
|
/// Scrolling switches focus between tabs.
|
||||||
|
pub(super) scrollable_focus: bool,
|
||||||
/// Show the close icon only when item is hovered.
|
/// Show the close icon only when item is hovered.
|
||||||
pub(super) show_close_icon_on_hover: bool,
|
pub(super) show_close_icon_on_hover: bool,
|
||||||
/// Padding around a button.
|
/// Padding around a button.
|
||||||
|
|
@ -115,6 +117,7 @@ where
|
||||||
model,
|
model,
|
||||||
id: None,
|
id: None,
|
||||||
close_icon: icon::from_name("window-close-symbolic").size(16).icon(),
|
close_icon: icon::from_name("window-close-symbolic").size(16).icon(),
|
||||||
|
scrollable_focus: false,
|
||||||
show_close_icon_on_hover: false,
|
show_close_icon_on_hover: false,
|
||||||
button_padding: [4, 4, 4, 4],
|
button_padding: [4, 4, 4, 4],
|
||||||
button_height: 32,
|
button_height: 32,
|
||||||
|
|
@ -541,6 +544,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.scrollable_focus {
|
||||||
if let Some(on_activate) = self.on_activate.as_ref() {
|
if let Some(on_activate) = self.on_activate.as_ref() {
|
||||||
if let Event::Mouse(mouse::Event::WheelScrolled { delta }) = event {
|
if let Event::Mouse(mouse::Event::WheelScrolled { delta }) = event {
|
||||||
let current = Instant::now();
|
let current = Instant::now();
|
||||||
|
|
@ -594,6 +598,7 @@ where
|
||||||
} else {
|
} else {
|
||||||
state.hovered = Item::None;
|
state.hovered = Item::None;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if state.focused {
|
if state.focused {
|
||||||
if let Event::Keyboard(keyboard::Event::KeyPressed {
|
if let Event::Keyboard(keyboard::Event::KeyPressed {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue