pub enum WidgetActionBinding {
Action(WidgetActionId),
Command(CommandId),
}Variants§
Action(WidgetActionId)
Command(CommandId)
Implementations§
Source§impl WidgetActionBinding
impl WidgetActionBinding
Sourcepub fn action(id: impl Into<WidgetActionId>) -> Self
pub fn action(id: impl Into<WidgetActionId>) -> Self
Examples found in repository?
examples/showcase.rs (lines 4449-4452)
4215fn showcase_window_descriptors(
4216 state: &ShowcaseState,
4217 desktop_state: &ext_widgets::FloatingDesktopState,
4218 desktop_size: UiSize,
4219) -> Vec<ext_widgets::FloatingWindowDescriptor> {
4220 let wide = (desktop_size.width - 36.0).clamp(320.0, 720.0);
4221 let medium = (desktop_size.width - 36.0).clamp(300.0, 604.0);
4222 let buttons_width = medium.min(620.0);
4223 let mut windows = Vec::new();
4224 push_window(
4225 &mut windows,
4226 state.windows.labels,
4227 "labels",
4228 "Labels",
4229 UiSize::new(380.0, 460.0),
4230 );
4231 push_window(
4232 &mut windows,
4233 state.windows.buttons,
4234 "buttons",
4235 "Buttons",
4236 UiSize::new(buttons_width, 220.0),
4237 );
4238 push_window(
4239 &mut windows,
4240 state.windows.checkbox,
4241 "checkbox",
4242 "Checkbox",
4243 UiSize::new(250.0, 72.0),
4244 );
4245 push_window(
4246 &mut windows,
4247 state.windows.toggles,
4248 "toggles",
4249 "Radio and toggles",
4250 UiSize::new(360.0, 320.0),
4251 );
4252 push_window(
4253 &mut windows,
4254 state.windows.slider,
4255 "slider",
4256 "Slider",
4257 UiSize::new(430.0, 560.0),
4258 );
4259 push_window(
4260 &mut windows,
4261 state.windows.numeric,
4262 "numeric",
4263 "Numeric input",
4264 UiSize::new(360.0, 180.0),
4265 );
4266 push_window(
4267 &mut windows,
4268 state.windows.text_input,
4269 "text_input",
4270 "Text input",
4271 UiSize::new(520.0, 560.0),
4272 );
4273 push_window(
4274 &mut windows,
4275 state.windows.selection,
4276 "selection",
4277 "Select controls",
4278 UiSize::new(300.0, 430.0),
4279 );
4280 push_window(
4281 &mut windows,
4282 state.windows.menus,
4283 "menus",
4284 "Menu controls",
4285 UiSize::new(wide, 520.0),
4286 );
4287 push_window(
4288 &mut windows,
4289 state.windows.command_palette,
4290 "command_palette",
4291 "Command palette",
4292 UiSize::new(280.0, 130.0),
4293 );
4294 push_window(
4295 &mut windows,
4296 state.windows.date_picker,
4297 "date_picker",
4298 "Date picker",
4299 UiSize::new(430.0, 390.0),
4300 );
4301 push_window(
4302 &mut windows,
4303 state.windows.color_picker,
4304 "color_picker",
4305 "Color picker",
4306 UiSize::new(340.0, 390.0),
4307 );
4308 push_window(
4309 &mut windows,
4310 state.windows.progress,
4311 "progress",
4312 "Progress indicator",
4313 UiSize::new(500.0, 168.0),
4314 );
4315 push_window(
4316 &mut windows,
4317 state.windows.animation,
4318 "animation",
4319 "Animation",
4320 UiSize::new(520.0, 430.0),
4321 );
4322 push_window(
4323 &mut windows,
4324 state.windows.easing,
4325 "easing",
4326 "Easing",
4327 UiSize::new(520.0, 450.0),
4328 );
4329 push_window(
4330 &mut windows,
4331 state.windows.lists_tables,
4332 "lists_tables",
4333 "Lists and tables",
4334 UiSize::new(600.0, 500.0),
4335 );
4336 push_window(
4337 &mut windows,
4338 state.windows.property_inspector,
4339 "property_inspector",
4340 "Property inspector",
4341 UiSize::new(330.0, 250.0),
4342 );
4343 push_window(
4344 &mut windows,
4345 state.windows.diagnostics,
4346 "diagnostics",
4347 "Diagnostics",
4348 UiSize::new(640.0, 760.0),
4349 );
4350 push_window(
4351 &mut windows,
4352 state.windows.trees,
4353 "trees",
4354 "Trees",
4355 UiSize::new(430.0, 390.0),
4356 );
4357 push_window(
4358 &mut windows,
4359 state.windows.layout_widgets,
4360 "layout_widgets",
4361 "Layout widgets",
4362 UiSize::new(wide.min(700.0), 430.0),
4363 );
4364 push_window(
4365 &mut windows,
4366 state.windows.containers,
4367 "containers",
4368 "Containers",
4369 UiSize::new(380.0, 520.0),
4370 );
4371 push_window(
4372 &mut windows,
4373 state.windows.panels,
4374 "panels",
4375 "Panels",
4376 UiSize::new(460.0, 280.0),
4377 );
4378 push_window(
4379 &mut windows,
4380 state.windows.forms,
4381 "forms",
4382 "Forms",
4383 UiSize::new(520.0, 620.0),
4384 );
4385 push_window(
4386 &mut windows,
4387 state.windows.overlays,
4388 "overlays",
4389 "Overlays",
4390 UiSize::new(620.0, 680.0),
4391 );
4392 push_window(
4393 &mut windows,
4394 state.windows.drag_drop,
4395 "drag_drop",
4396 "Drag and drop",
4397 UiSize::new(500.0, 460.0),
4398 );
4399 push_window(
4400 &mut windows,
4401 state.windows.media,
4402 "media",
4403 "Media",
4404 UiSize::new(520.0, 430.0),
4405 );
4406 push_window(
4407 &mut windows,
4408 state.windows.shaders,
4409 "shaders",
4410 "Shader effects",
4411 UiSize::new(500.0, 410.0),
4412 );
4413 push_window(
4414 &mut windows,
4415 state.windows.shader_lab,
4416 "shader_lab",
4417 "Shader lab",
4418 UiSize::new(1000.0, 700.0),
4419 );
4420 push_window(
4421 &mut windows,
4422 state.windows.timeline,
4423 "timeline",
4424 "Timeline",
4425 UiSize::new(600.0, 120.0),
4426 );
4427 push_window(
4428 &mut windows,
4429 state.windows.canvas,
4430 "canvas",
4431 "Canvas",
4432 UiSize::new(760.0, 500.0),
4433 );
4434 push_window(
4435 &mut windows,
4436 state.windows.theme,
4437 "theme",
4438 "Theme",
4439 UiSize::new(430.0, 360.0),
4440 );
4441 push_window(
4442 &mut windows,
4443 state.windows.styling,
4444 "styling",
4445 "Styling",
4446 UiSize::new(540.0, 440.0),
4447 );
4448 for window in &mut windows {
4449 window.drag_action = Some(WidgetActionBinding::action(format!(
4450 "window.drag.{}",
4451 window.id
4452 )));
4453 window.collapse_action = Some(WidgetActionBinding::action(format!(
4454 "window.collapse.{}",
4455 window.id
4456 )));
4457 window.resize_action = Some(WidgetActionBinding::action(format!(
4458 "window.resize.{}",
4459 window.id
4460 )));
4461 desktop_state.apply_to_descriptor(window, window_defaults(window.id.as_str()));
4462 }
4463 windows
4464}pub fn command(id: impl Into<CommandId>) -> Self
Sourcepub const fn action_id(&self) -> Option<&WidgetActionId>
pub const fn action_id(&self) -> Option<&WidgetActionId>
Examples found in repository?
More examples
examples/simple_form.rs (line 35)
34 fn update(&mut self, action: WidgetAction) {
35 let Some(action_id) = action.binding.action_id().map(|id| id.as_str()) else {
36 return;
37 };
38 match action_id {
39 "form.name.edit" => apply_text_edit(&mut self.name, &action.kind),
40 "form.email.edit" => apply_text_edit(&mut self.email, &action.kind),
41 "form.submit" => {
42 self.submitted = format!("Submitted {} <{}>", self.name.text(), self.email.text());
43 }
44 _ => {}
45 }
46 }examples/command_palette_hotkeys.rs (line 35)
34 fn update(&mut self, action: WidgetAction) {
35 let Some(action_id) = action.binding.action_id().map(|id| id.as_str()) else {
36 return;
37 };
38 let items = command_items();
39 if action_id == "commands.search" {
40 if let WidgetActionKind::TextEdit(edit) = &action.kind {
41 if edit.local_position.is_none() {
42 if let Some(selection) = self.palette.handle_event(&items, &edit.event).selected
43 {
44 self.last_command = selection.id;
45 }
46 }
47 }
48 } else if let Some(command) = action_id.strip_prefix("commands.item.") {
49 self.last_command = command.to_string();
50 }
51 }pub const fn command_id(&self) -> Option<&CommandId>
Trait Implementations§
Source§impl Clone for WidgetActionBinding
impl Clone for WidgetActionBinding
Source§fn clone(&self) -> WidgetActionBinding
fn clone(&self) -> WidgetActionBinding
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WidgetActionBinding
impl Debug for WidgetActionBinding
Source§impl From<&str> for WidgetActionBinding
impl From<&str> for WidgetActionBinding
Source§impl From<CommandId> for WidgetActionBinding
impl From<CommandId> for WidgetActionBinding
Source§impl From<String> for WidgetActionBinding
impl From<String> for WidgetActionBinding
Source§impl From<WidgetActionId> for WidgetActionBinding
impl From<WidgetActionId> for WidgetActionBinding
Source§fn from(value: WidgetActionId) -> Self
fn from(value: WidgetActionId) -> Self
Converts to this type from the input type.
Source§impl Hash for WidgetActionBinding
impl Hash for WidgetActionBinding
Source§impl PartialEq for WidgetActionBinding
impl PartialEq for WidgetActionBinding
Source§fn eq(&self, other: &WidgetActionBinding) -> bool
fn eq(&self, other: &WidgetActionBinding) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for WidgetActionBinding
impl StructuralPartialEq for WidgetActionBinding
Auto Trait Implementations§
impl Freeze for WidgetActionBinding
impl RefUnwindSafe for WidgetActionBinding
impl Send for WidgetActionBinding
impl Sync for WidgetActionBinding
impl Unpin for WidgetActionBinding
impl UnsafeUnpin for WidgetActionBinding
impl UnwindSafe for WidgetActionBinding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.