Modify

#20624 closed enhancement (fixed)

keyboard shortcut to copy url to osm element in clipboard

Reported by: StephaneP Owned by: GerdP
Priority: normal Milestone: 21.04
Component: Core shortcuts Version:
Keywords: shortcut, url, clipboard Cc:

Description

When I edit Osm inside Josm and need to create a discussion on a changeset, I often have to add a link to a node/way/relation/changeset inside the discussion.
To do this I have to select the element then press ctrl+shift+i, copy the url from the just opened browser tab, and paste it in the discussion.

It would be faster if we can have a keyboard shortcut to copy this url directly to the clipboard, without opening a web browser.
We could make this shortcut available for node, way, relation, changeset, user.
An available shortcut is Ctrl+Alt+l

Attachments (4)

20624.patch (3.8 KB) - added by GerdP 14 months ago.
20624.2.patch (3.8 KB) - added by GerdP 14 months ago.
enable action only when at least one non-new object is selected
20624.3.patch (3.8 KB) - added by GerdP 14 months ago.
"Copy server url", also use selected deleted objects
20624.with-notes.patch (4.3 KB) - added by GerdP 14 months ago.
My experimental code reg. notes

Download all attachments as: .zip

Change History (28)

comment:1 Changed 15 months ago by StephaneP

Component: CoreCore shortcuts

comment:2 Changed 15 months ago by GerdP

I thought about adding the link to the text box shown with Ctrl+I. This would also mean that you mark the line and use copy first but at least it should be much faster.

comment:3 in reply to:  2 ; Changed 14 months ago by skyper

+1, similar to Ctrl+C copying internally the object ids, this action would add all urls of selected objects. May be shorten as https://www.osm.org/*.

Found some available shortcuts:

  • questionmark: ?
  • Alt+INSERT
  • Alt+Ctrl+Shift+Y
  • Alt+Ctrl+Shift+Z

Replying to GerdP:

I thought about adding the link to the text box shown with Ctrl+I. This would also mean that you mark the line and use copy first but at least it should be much faster.

As the info dialog is non-modal, I would have to open it several times when more than one object is selected without a summary on top. Already, have problems with that when copying the id of several, locally deleted objects where Ctrl+C does not work.

comment:4 Changed 14 months ago by simon04

Similar to "Copy Coordinates", we could offer a similar action and allow users to assign their favourite shortcut. Not all users will need this action, and shortcuts with four keys are not really easy to memorise.

comment:5 Changed 14 months ago by GerdP

Owner: changed from team to GerdP
Status: newassigned

Changed 14 months ago by GerdP

Attachment: 20624.patch added

comment:6 Changed 14 months ago by GerdP

patch implements a new (expert-only) action without predefined shortcut and shows it in the edit menu below "Copy Coordinates".
Please review the new i18n strings:

        super(tr("Copy URLs"), "copy",
                tr("Copy URLs of selected objects to clipboard."),
                Shortcut.registerShortcut("copy:urls", tr("Edit: {0}", tr("Copy URLs")),
                        KeyEvent.CHAR_UNDEFINED, Shortcut.NONE),
                false);

Action is enabled when at least one primitive is selected. Should I add a filter so that at least one already uploaded node, way, or relation must be selected?

comment:7 in reply to:  3 ; Changed 14 months ago by GerdP

Replying to skyper:

May be shorten as https://www.osm.org/*.

See preference osm-browse.url which defaults to https://www.openstreetmap.org.
Maybe the default should be changed?

comment:8 in reply to:  6 Changed 14 months ago by StephaneP

Replying to GerdP:

Should I add a filter so that at least one already uploaded node, way, or relation must be selected?

I think so.

Changed 14 months ago by GerdP

Attachment: 20624.2.patch added

enable action only when at least one non-new object is selected

comment:9 in reply to:  7 ; Changed 14 months ago by skyper

Thanks, does it work with deleted or incomplete objects? Ctrl+C does not work with them.

Replying to simon04:

Similar to "Copy Coordinates", we could offer a similar action and allow users to assign their favourite shortcut. Not all users will need this action, and shortcuts with four keys are not really easy to memorise.

Fine, I will use ? or Alt+Insert

Replying to GerdP:

Replying to skyper:

May be shorten as https://www.osm.org/*.

Even osm.org works.

See preference osm-browse.url which defaults to https://www.openstreetmap.org.
Maybe the default should be changed?

No, if it is used globally, pointing to redirects, on default, may be not the best solution. Documentation should just mention this option.

comment:10 in reply to:  9 Changed 14 months ago by GerdP

Replying to skyper:

Thanks, does it work with deleted or incomplete objects? Ctrl+C does not work with them.

So far it ignores deleted objects. Will change that. I've never noticed that incomplete objects are special. Please double check.

comment:11 Changed 14 months ago by skyper

How about adding "Server" to the description: Copy server URLs of selected objects to clipboard.

comment:12 Changed 14 months ago by skyper

Sorry, you are right, incomplete objects work, so only deleted are special.

Changed 14 months ago by GerdP

Attachment: 20624.3.patch added

"Copy server url", also use selected deleted objects

comment:13 Changed 14 months ago by simon04

Maybe reuse code from InfoWebAction (it also supports notes)? I'm trying to think of a more concise name for the menu entry, maybe "Advanced info (copy web URL)"?

comment:14 Changed 14 months ago by GerdP

I started with the idea to reuse code from InfoWebAction but failed to code the constructor. When I extend AbstractInfoAction instead I'll also end up duplicating the code in InfoWebAction

comment:15 Changed 14 months ago by GerdP

I'll try to change InfoWebAction similar to the code in CreateMultipolygonAction so that a boolean decides what the action does.

comment:16 Changed 14 months ago by GerdP

Nah, code gets too complicated. I give up with this idea.
I also don't think that notes are relevant for this action, but I've noticed that the existing code doesn't check if a note has a positive id.

Changed 14 months ago by GerdP

Attachment: 20624.with-notes.patch added

My experimental code reg. notes

comment:17 Changed 14 months ago by GerdP

@simon04: I don't understand the meaning of the registerInToolbar parameter. Should it be true or false? What's the criteria?

comment:18 Changed 14 months ago by simon04

Milestone: 21.04

Patch works as expected. :-)

Ad registerInToolbar: set it to true if users should be able to add this entry to the toolbar. If false, this entry will not show up in the toolbar preferences. https://github.com/openstreetmap/josm/blob/16fb463b5b69df9b710f72f1b928744f20731e2e/src/org/openstreetmap/josm/actions/JosmAction.java#L104-L106

comment:19 Changed 14 months ago by simon04

Keywords: clipboard added

comment:20 Changed 14 months ago by GerdP

What are the toolbar preferences? I think I used parameter false and I was still able to add the action to the toolbar.

comment:21 in reply to:  20 Changed 14 months ago by stoecker

Replying to GerdP:

What are the toolbar preferences? I think I used parameter false and I was still able to add the action to the toolbar.

Actions used in the menu are always available for toolbars. Not 100% sure, but this parameter probably is only needed for actions which aren't available via the main menu. But it nevertheless should be set correctly in any case.

comment:22 Changed 14 months ago by GerdP

Sorry for the delay. Which patch should I use? 20624.with-notes.patch or 20624.3.patch

comment:23 Changed 14 months ago by simon04

I'd go with the attachment:20624.with-notes.patch​ (in order to be consistent with the other "info actions").

comment:24 Changed 14 months ago by GerdP

Resolution: fixed
Status: assignedclosed

In 17767/josm:

fix #20624: keyboard shortcut to copy url to osm element in clipboard

  • new action to copy urls of selected OSM elements and notes

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain GerdP.
as The resolution will be set.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.