简体   繁体   中英

How to set Pharo keyboard shortcut for switching windows?

I have read that in Pharo it's possible to switch between windows using Alt-Tab. But I've never been able to test this, because both OSes I commonly use capture Alt-Tab and use it for their own window switching.

I can't find a listing for Alt-Tab in the system Keymap Browser. Where is the key to switch windows defined, and how can I change it?

EDIT: I'd also love a "here's how you could have found out for yourself" type answer.

well... you hit one of our weaker spots :)

Keybindings are not in his best shape, but:

  • Actually, alt+tab is already set to "switch window" activity. The problem is that does not work all the time (for example, it does not work on Playground).
  • This is because there are some hardcoded logic there, who we are removing slowly from the system (some of those parts have more than 15yrs since they come from before Pharo has born).
  • Someone (probably in a failed attempt to fix the playground, or the hardcodes) forget a halt in the method who creates a new preview window... so even if you reach that part of the system, you will have a debugger. Of course, you will be able to restore correct behaviour by just removing the breakpoint, but that will not correct the fact "switch windows" will not be available everywhere.
  • I opened a bug entry for it: https://pharo.fogbugz.com/f/cases/15546 , in case you want to follow the issue (you will need an account there, I'm sorry for that).

In any case, we are moving out this hardcode stuff, and you can check all currently available settings going to World Menu/System/Keymap Browser (they are a lot, we are also playing with ideas on how to show better this combinations... emacs style, popup notifications, etc.)

I got this working by editing the "Basic, general navigation shortcuts among morphs" in package Morhpic-Core>>Kernel edit Morph class>>#morphNavigationShortcutsOn:

There you can create shortcuts for "World navigateWindowForward" etc. Took me a while to find keys that worked ok, most don't work well when in a textfield. I'm using the following:

<keymap>
(aBuilder shortcut: #navigateFocusForwardCtrl)
    category: #MorphFocusCtrlNavigation
    default: $j ctrl asKeyCombination
    do: [ :target :morph :event | morph navigateFocusForward ].
(aBuilder shortcut: #navigateFocusBackwardCtrl)
    category: #MorphFocusCtrlNavigation
    default: $k ctrl asKeyCombination
    do: [ :target :morph :event | morph navigateFocusBackward ].
(aBuilder shortcut: #navigateVisibleWindowForward)
    category: #MorphFocusCtrlNavigation
    default: Character tab ctrl asKeyCombination
    do: [ :target :morph :event | World navigateVisibleWindowForward ].
(aBuilder shortcut: #navigateWindowForward)
    category: #MorphFocusCtrlNavigation
    default: $l ctrl asKeyCombination
    do: [ :target :morph :event | World navigateWindowForward ].
(aBuilder shortcut: #navigateWindowBackward)
    category: #MorphFocusCtrlNavigation
    default: $; ctrl asKeyCombination
    do: [ :target :morph :event | World navigateWindowBackward  ]

although the category probably isn't correct, it works... (whereas #MorphFocusNavigation doesn't!)

Using the hallo menu bring up an inspector on a window object. Then in the inspector switch to the 'Keys' tab. There you can see all the shortcuts associated with the morph. Selecting the one that you are interested in (Alt+TAB) will open a new inspector pane to the right. The 'Source code' shows and highlights the source code where the keybinding is defined. Browse the method, edit it, save it, reset the key mappings (KMRepository reset) and you should be done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM