use zng_app::access::*;
use zng_view_api::access::AccessCmdName;
use zng_wgt::prelude::*;
event_property! {
pub fn access_click {
event: ACCESS_CLICK_EVENT,
args: AccessClickArgs,
with: access_click,
}
pub fn access_expander {
event: ACCESS_EXPANDER_EVENT,
args: AccessExpanderArgs,
with: access_expander,
}
pub fn access_increment {
event: ACCESS_INCREMENT_EVENT,
args: AccessIncrementArgs,
with: access_increment,
}
pub fn access_tooltip {
event: ACCESS_TOOLTIP_EVENT,
args: AccessToolTipArgs,
with: access_tooltip,
}
pub fn access_scroll {
event: ACCESS_SCROLL_EVENT,
args: AccessScrollArgs,
with: access_scroll,
}
pub fn access_text {
event: ACCESS_TEXT_EVENT,
args: AccessTextArgs,
with: access_text,
}
pub fn access_number {
event: ACCESS_NUMBER_EVENT,
args: AccessNumberArgs,
with: access_number,
}
pub fn access_selection {
event: ACCESS_SELECTION_EVENT,
args: AccessSelectionArgs,
with: access_selection,
}
}
fn access_click(child: impl UiNode, _: bool) -> impl UiNode {
access_capable(child, AccessCmdName::Click)
}
fn access_expander(child: impl UiNode, _: bool) -> impl UiNode {
access_capable(child, AccessCmdName::SetExpanded)
}
fn access_increment(child: impl UiNode, _: bool) -> impl UiNode {
access_capable(child, AccessCmdName::Increment)
}
fn access_tooltip(child: impl UiNode, _: bool) -> impl UiNode {
access_capable(child, AccessCmdName::SetToolTipVis)
}
fn access_scroll(child: impl UiNode, _: bool) -> impl UiNode {
access_capable(child, AccessCmdName::Scroll)
}
fn access_text(child: impl UiNode, _: bool) -> impl UiNode {
match_node(child, move |_, op| {
if let UiNodeOp::Info { info } = op {
if let Some(mut access) = info.access() {
access.push_command(AccessCmdName::SetString);
access.push_command(AccessCmdName::ReplaceSelectedText);
}
}
})
}
fn access_number(child: impl UiNode, _: bool) -> impl UiNode {
access_capable(child, AccessCmdName::SetNumber)
}
fn access_selection(child: impl UiNode, _: bool) -> impl UiNode {
access_capable(child, AccessCmdName::SelectText)
}
fn access_capable(child: impl UiNode, cmd: AccessCmdName) -> impl UiNode {
match_node(child, move |_, op| {
if let UiNodeOp::Info { info } = op {
if let Some(mut access) = info.access() {
access.push_command(cmd)
}
}
})
}