@@ -37,10 +37,10 @@ use crate::{
37
37
AssetSource , BackgroundExecutor , Bounds , ClipboardItem , CursorStyle , DispatchPhase , DisplayId ,
38
38
EventEmitter , FocusHandle , FocusMap , ForegroundExecutor , Global , KeyBinding , KeyContext ,
39
39
Keymap , Keystroke , LayoutId , Menu , MenuItem , OwnedMenu , PathPromptOptions , Pixels , Platform ,
40
- PlatformDisplay , PlatformKeyboardLayout , Point , PromptBuilder , PromptButton , PromptHandle ,
41
- PromptLevel , Render , RenderImage , RenderablePromptHandle , Reservation , ScreenCaptureSource ,
42
- SubscriberSet , Subscription , SvgRenderer , Task , TextSystem , Window , WindowAppearance ,
43
- WindowHandle , WindowId , WindowInvalidator ,
40
+ PlatformDisplay , PlatformKeyboardLayout , PlatformKeyboardMapper , Point , PromptBuilder ,
41
+ PromptButton , PromptHandle , PromptLevel , Render , RenderImage , RenderablePromptHandle ,
42
+ Reservation , ScreenCaptureSource , SubscriberSet , Subscription , SvgRenderer , Task , TextSystem ,
43
+ Window , WindowAppearance , WindowHandle , WindowId , WindowInvalidator ,
44
44
colors:: { Colors , GlobalColors } ,
45
45
current_platform, hash, init_app_menus,
46
46
} ;
@@ -263,6 +263,7 @@ pub struct App {
263
263
pub ( crate ) focus_handles : Arc < FocusMap > ,
264
264
pub ( crate ) keymap : Rc < RefCell < Keymap > > ,
265
265
pub ( crate ) keyboard_layout : Box < dyn PlatformKeyboardLayout > ,
266
+ pub ( crate ) keyboard_mapper : Rc < dyn PlatformKeyboardMapper > ,
266
267
pub ( crate ) global_action_listeners :
267
268
FxHashMap < TypeId , Vec < Rc < dyn Fn ( & dyn Any , DispatchPhase , & mut Self ) > > > ,
268
269
pending_effects : VecDeque < Effect > ,
@@ -312,6 +313,7 @@ impl App {
312
313
let text_system = Arc :: new ( TextSystem :: new ( platform. text_system ( ) ) ) ;
313
314
let entities = EntityMap :: new ( ) ;
314
315
let keyboard_layout = platform. keyboard_layout ( ) ;
316
+ let keyboard_mapper = platform. keyboard_mapper ( ) ;
315
317
316
318
let app = Rc :: new_cyclic ( |this| AppCell {
317
319
app : RefCell :: new ( App {
@@ -337,6 +339,7 @@ impl App {
337
339
focus_handles : Arc :: new ( RwLock :: new ( SlotMap :: with_key ( ) ) ) ,
338
340
keymap : Rc :: new ( RefCell :: new ( Keymap :: default ( ) ) ) ,
339
341
keyboard_layout,
342
+ keyboard_mapper,
340
343
global_action_listeners : FxHashMap :: default ( ) ,
341
344
pending_effects : VecDeque :: new ( ) ,
342
345
pending_notifications : FxHashSet :: default ( ) ,
@@ -376,6 +379,7 @@ impl App {
376
379
if let Some ( app) = app. upgrade ( ) {
377
380
let cx = & mut app. borrow_mut ( ) ;
378
381
cx. keyboard_layout = cx. platform . keyboard_layout ( ) ;
382
+ cx. keyboard_mapper = cx. platform . keyboard_mapper ( ) ;
379
383
cx. keyboard_layout_observers
380
384
. clone ( )
381
385
. retain ( & ( ) , move |callback| ( callback) ( cx) ) ;
@@ -424,6 +428,11 @@ impl App {
424
428
self . keyboard_layout . as_ref ( )
425
429
}
426
430
431
+ /// Get the current keyboard mapper.
432
+ pub fn keyboard_mapper ( & self ) -> & Rc < dyn PlatformKeyboardMapper > {
433
+ & self . keyboard_mapper
434
+ }
435
+
427
436
/// Invokes a handler when the current keyboard layout changes
428
437
pub fn on_keyboard_layout_change < F > ( & self , mut callback : F ) -> Subscription
429
438
where
0 commit comments