Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platforms/windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ windows-core = "0.61.0"
version = "0.61.1"
features = [
"Win32_Foundation",
"Win32_Globalization",
"Win32_Graphics_Gdi",
"Win32_System_Com",
"Win32_System_LibraryLoader",
Expand Down
1 change: 1 addition & 0 deletions platforms/windows/examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl InnerWindowState {
if self.announcement.is_some() {
node.push_child(ANNOUNCEMENT_ID);
}
node.set_language("en");
node
}
}
Expand Down
5 changes: 5 additions & 0 deletions platforms/windows/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ impl NodeWrapper<'_> {
self.0.description()
}

fn culture(&self) -> Option<LocaleName<'_>> {
self.0.language().map(LocaleName)
}

fn placeholder(&self) -> Option<&str> {
self.0.placeholder()
}
Expand Down Expand Up @@ -962,6 +966,7 @@ properties! {
(UIA_LocalizedControlTypePropertyId, localized_control_type),
(UIA_NamePropertyId, name),
(UIA_FullDescriptionPropertyId, description),
(UIA_CulturePropertyId, culture),
(UIA_HelpTextPropertyId, placeholder),
(UIA_IsContentElementPropertyId, is_content_element),
(UIA_IsControlElementPropertyId, is_content_element),
Expand Down
11 changes: 11 additions & 0 deletions platforms/windows/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use windows::{
core::*,
Win32::{
Foundation::*,
Globalization::*,
Graphics::Gdi::*,
System::{Com::*, Ole::*, Variant::*},
UI::{Accessibility::*, WindowsAndMessaging::*},
Expand Down Expand Up @@ -43,6 +44,16 @@ impl From<WideString> for BSTR {
}
}

#[derive(Debug, PartialEq, Eq)]
pub(crate) struct LocaleName<'a>(pub(crate) &'a str);

impl From<LocaleName<'_>> for Variant {
fn from(value: LocaleName) -> Self {
let lcid = unsafe { LocaleNameToLCID(&HSTRING::from(value.0), LOCALE_ALLOW_NEUTRAL_NAMES) };
(lcid != 0).then_some(lcid as i32).into()
}
}

pub(crate) struct Variant(VARIANT);

impl From<Variant> for VARIANT {
Expand Down