Opened 13 years ago

Last modified 6 months ago

#5515 reopened enhancement

Single Key Shortcuts for activating and showing/hiding layers

Reported by: AlfonZ Owned by: jttt
Priority: normal Milestone:
Component: Core shortcuts Version:
Keywords: layer shortcut Cc: stefanct, chriswhy

Description (last modified by Hb---)

Reopened with a request for Single Key Shortcuts, see comment 25

I'd like to activate, show & hide layers using just keyboard shortcuts.

I have prepared a patch that creates shortcuts for this.
There will be 10 shortcuts for activating and 10 shortcuts for showing/hiding layers.
At first I thought to assign them to CTRL-1 to CTRL-0 and CTRL-SHIFT-1 to CTRL-SHIFT-0, but I wasn't sure if that's the right choice so I left them unassigned and user has to configure them in preferences.
Layers will be index-referenced. Does anybody use more than 10 layers at once?

This is my first patch for JOSM, so it needs proper review, especially shortcut names and texts for translation. Any feedback is welcome.

Attachments (1)

LayerShortcuts.diff (4.0 KB) - added by AlfonZ 13 years ago.

Download all attachments as: .zip

Change History (35)

Changed 13 years ago by AlfonZ

Attachment: LayerShortcuts.diff added


comment:1 Changed 12 years ago by PJHouser

Description: modified (diff)

Ability to toggle between layers exists in the latest version 4542, but the ability to activate different layers with keyboard shortcuts does not seem to exist yet. This would be extremely handy because I regularly layer different datasets to update OSM, and switching between mouse and shortcuts is frustrating.

comment:2 Changed 12 years ago by jttt

I'm working on adding multikey shortcuts that should solve this (feature inspired by shortcuts in eclipse). When finished, it would be possible to activate for example third layer by pressing Ctrl+Alt+A,3. I'm going to add shortcuts for activate layer, show/hide layer, jump to previous marker and jump to next marker.

comment:3 Changed 12 years ago by jttt

Owner: changed from team to jttt

comment:4 Changed 12 years ago by jttt

Resolution: fixed
Status: newclosed

In [4596/josm]:

Fix #5515 Shortcuts for activating and showing/hiding layers

comment:5 Changed 12 years ago by PJHouser

Resolution: fixed
Status: closedreopened

I can't get it to work.

comment:6 Changed 12 years ago by jttt

  • right click on data layer to see what shortcut is assigned for activating/hiding layers
  • press shortcut and wait few seconds
  • popup menu should be shown in right-bottom border with list of layers and assigned layer index
  • press key assigned to layer

At which point it doesn't work? You don't have to always wait for menu to show up, you can press layer index key immediately. It's possible that selected shortcut doesn't work on your system, please try it with Activate layer, Show/hide layer and in Marker layer with Jump to next/previous marker.

comment:7 Changed 12 years ago by akks

Unfortunately, it is relly hard to make it work stable too. I have even removed all plugins...
The problem tis that popup is shown very rarely and in random moments:) Maybe Windows-specific problem?
Sometimes popup appear after several mouse clicks or even after switching the window...

It aclually performs layer switching by ctrl-alt-a,2 etc., but it took me 1/4 of an hour after reading this post s to learn this trick.

Last edited 12 years ago by akks (previous) (diff)

comment:8 Changed 12 years ago by akks

After looking at the source and debugging I figured it)

You need to
1) Press ctrl-alt-a, fast (do not hold it)
2) Do not press anything more!
3) Wait for 2 seconds - popup will appear.

I wonder, how to make it more clear for users...
Maybe, interval should be less? About 1 second or even less.
Elsewhere user will do something and will not notice anything.

Maybe, it would be better to show popup immediately, and REMOVE it after other clicks/keys (like now) or after 2 seconds (if there was no action).

And please renumber the layers - "0" button is too far from others, and not all of the mappers are programmers :)

Last edited 12 years ago by akks (previous) (diff)

comment:9 Changed 12 years ago by jttt

I'll renumber it from 1, I didn't realize there is anything wrong with starting with zero ;-)

In normal usecase, it should be enough to press ctrl+alt+a and 1 to activate first layer (it's not necessary to release ctrl+alt). Popup menu is only additional hint in case user has lots of layers or doesn't know how this feature work. Thats reason for quite long interval, I didn't want popup menu to be shown every time. But 1 second should work fine.

This feature was inspired by similar feature in Eclipse, where after initial shortcut (ctrl+alt+a) is pressed it's shown in status bar and after some time menu is shown. Do you think it would help if after ctrl+alt+a is pressed, in status bar would appear "Activate layers" (and nothing else happened) and after 1 second menu would be shown?

comment:10 Changed 12 years ago by akks

Yes, I think status message, 1 second pause and renumbering will be enough to make it more obvious :)

Maybe message "Activate layer ...[please type its number]" or something like it will help)

I almost forget to thank you for this feature - it is really important and powerful!

comment:11 Changed 12 years ago by jttt

In [4604/josm]:

Multikey action improvements (see #5515):

  • show text in status bar after shortcut is pressed
  • number layers from 1
  • do not allow Repeat for last layer if layer index conflicts with shortcut

comment:12 Changed 12 years ago by jttt

I did some changes, I hope it's easier to understand now. It's quite trivial to add new multikey actions, do you have some suggestions which layer (or any other list) actions should be added?

comment:13 Changed 12 years ago by akks

Multikey shortcut for custom search actions (does not have a list, unfortunately) and/or filters can be useful, but I do not how many users use them intensively.

comment:14 Changed 12 years ago by akks

The behaviour is clear now, thank you!

But, I am afraid, popup text is invisible :) Just a gray rectangle with working menu items... Maybe, some internationalization issue.
It does not depend on system locale and Windows 7 Aero on/off (I checked). Also there are no error/warning messages in command line.

Last edited 12 years ago by akks (previous) (diff)

comment:15 Changed 12 years ago by jttt

Do you mean popup title (name of action) or all entries? Did it work before? I've tested that only in linux, but I have WinXP in virtual box so I can try it there. If it's only title then it's probably caused by formatting (I've tried to make it centered and in italic).

Shorcuts for custom search/filters should be possible, I'll have a look at it.

comment:16 Changed 12 years ago by akks

All the entries are invisible, but clickable. There is no such problem in my Ubuntu VirtualBox :) (shortcut is itaic too, by the way).

comment:17 Changed 12 years ago by jttt

It works fine in WinXP, you can try josm from, it has only removed italics for shorcuts. Otherwise it's completely standard popup menu, I have no idea why it shouldn't work in Win7

comment:18 Changed 12 years ago by akks

The problem persists on Win7...
I am looking at the code...

comment:19 Changed 12 years ago by akks

The problem is in

If you remove this line, all works perfectly.

comment:20 Changed 12 years ago by jttt

In [4615/josm]:

Use different way to center popup menu title to prevent blank menu on Windows 7, add shortcuts to enable/hiding of filters (see #5515)

comment:21 Changed 12 years ago by akks

Thank you!

Another simple idea - turn on/off map styles by multikey shortcut (we have only Ctrl-W for wireframe mode)

comment:22 Changed 12 years ago by akks

I think it works well now and the shortcuts Shift-A, Shift-S ar suitable :)

comment:23 Changed 12 years ago by akks

Resolution: fixed
Status: reopenedclosed

comment:24 Changed 12 years ago by skyper

Ticket #7343 has been marked as a duplicate of this ticket.

comment:25 Changed 11 years ago by stefanct

Resolution: fixed
Status: closedreopened

i would like to have non-multikey shortcuts because they are still faster and more convenient (when importing data i need to switch between two data layers quite a lot to compare the features). i would not mind if there would be no keys assigned to it by default as long as i could assign them in the configuration menu. does anybody want to work on this? can some regular dev please tell me if such a patch would be merged? (should i open another ticket instead?)

comment:26 Changed 11 years ago by stefanct

Cc: stefanct added

comment:27 Changed 10 years ago by Don-vip

Component: CoreCore shortcuts

comment:28 Changed 5 years ago by Hb---

Description: modified (diff)
Summary: Shortcuts for activating and showing/hiding layersSingle Key Shortcuts for activating and showing/hiding layers

comment:29 Changed 2 years ago by chriswhy

When I right-click on a layer in the Layers box, there is a shortcut shown there: Shift-S. Why does this only work within the context menu? Does Shift-S have another use within JOSM?

comment:30 Changed 2 years ago by chriswhy

Cc: chriswhy added

comment:31 Changed 2 years ago by skyper

comment:32 Changed 2 years ago by chriswhy

@skyper, thanks, just what I was looking for.

comment:33 Changed 6 months ago by Will <will@…>

Shift+A does nothing for me. Maybe because I have the MapWithAI plugin installed and that uses Shift+A for another purpose?

comment:34 Changed 6 months ago by GerdP

You can assign a different shortcut. See

Modify Ticket

Change Properties
Set your email in Preferences
as reopened The owner will remain jttt.
as The resolution will be set.
to The owner will be changed from jttt to the specified user.
The owner will change to AlfonZ
as duplicate The resolution will be set to duplicate.The specified ticket will be cross-referenced with this ticket

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.