-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
UIAll things user interface relatedAll things user interface relatedenhancementNew feature or requestNew feature or requestlambda-rsIssues pertaining to the core frameworkIssues pertaining to the core framework
Description
Overview
Add a button widget that responds to mouse clicks and displays text or an icon.
Current State
No response
Scope
Goals:
- Text button with label
- Click detection
- Visual states (normal, hover, pressed, disabled)
- Callback on click
Non-Goals:
- Icon buttons
- Toggle buttons
- Styling
Proposed API
pub enum ButtonState {
Normal,
Hovered,
Pressed,
Disabled,
}
pub struct Button {
label: String,
state: ButtonState,
on_click: Option<Box<dyn Fn()>>,
}
impl Button {
pub fn new(label: &str) -> Self;
pub fn on_click(self, callback: impl Fn() + 'static) -> Self;
pub fn set_enabled(&mut self, enabled: bool);
pub fn state(&self) -> ButtonState;
}
impl Widget for Button {
fn render(&self, ctx: &mut UiRenderContext) -> Vec<RenderCommand>;
fn hit_test(&self, x: f32, y: f32) -> bool;
// Mouse event handling internally updates state
}Acceptance Criteria
- Button displays label text
- Hover state when mouse over
- Pressed state when mouse down
- Click callback fires on mouse up inside
- Disabled state ignores i
Affected Crates
lambda-rs
Notes
- State transitions: Normal <-> Hovered <-> Pressed
- Click fires only if release is inside button
Metadata
Metadata
Assignees
Labels
UIAll things user interface relatedAll things user interface relatedenhancementNew feature or requestNew feature or requestlambda-rsIssues pertaining to the core frameworkIssues pertaining to the core framework