1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Dropdown event consumption.
//!
//! Level-1 hit registration and keyboard helpers stay in [`super::input`].
//!
//! ```
//! use uzor::layout::DispatchEvent;
//! use uzor::ui::widgets::composite::dropdown::consume::{consume_event, ConsumeEventCtx};
//! use uzor::ui::widgets::composite::dropdown::DropdownState;
//! use uzor::{Rect, WidgetId};
//!
//! let mut state = DropdownState::default();
//! let host = WidgetId::from("dropdown-widget");
//! let ctx = ConsumeEventCtx {
//! cursor: (0.0, 0.0),
//! frame_rect: Rect::new(0.0, 0.0, 180.0, 80.0),
//! viewport: (800.0, 600.0),
//! };
//! let event = DispatchEvent::Unhandled(WidgetId::from("other"));
//! assert!(consume_event(event, &mut state, &host, ctx).is_some());
//! ```
use DropdownState;
use crateDispatchEvent;
use crate;
/// Cursor position and view metadata for events that need spatial context.
///
/// Included for API uniformity with other composites; not used by dropdown
/// event handling today.
/// Consume a `DispatchEvent` if it belongs to this dropdown. Returns:
/// - `None` — the event was consumed (composite mutated its state).
/// - `Some(event)` — the event is not for this dropdown; pass it through.
///
/// `host_id` is the dropdown composite's WidgetId. Only events whose carried
/// `dropdown_id` equals `host_id` are consumed.