Modify

Opened 3 years ago

Closed 3 years ago

#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 3 years ago.
20624.2.patch (3.8 KB ) - added by GerdP 3 years ago.
enable action only when at least one non-new object is selected
20624.3.patch (3.8 KB ) - added by GerdP 3 years ago.
"Copy server url", also use selected deleted objects
20624.with-notes.patch (4.3 KB ) - added by GerdP 3 years ago.
My experimental code reg. notes

Download all attachments as: .zip

Change History (28)

comment:1 by StephaneP, 3 years ago

Component: CoreCore shortcuts

comment:2 by GerdP, 3 years ago

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.

in reply to:  2 ; comment:3 by skyper, 3 years ago

+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 by simon04, 3 years ago

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 by GerdP, 3 years ago

Owner: changed from team to GerdP
Status: newassigned

by GerdP, 3 years ago

Attachment: 20624.patch added

comment:6 by GerdP, 3 years ago

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?

in reply to:  3 ; comment:7 by GerdP, 3 years ago

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?

in reply to:  6 comment:8 by StephaneP, 3 years ago

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.

by GerdP, 3 years ago

Attachment: 20624.2.patch added

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

in reply to:  7 ; comment:9 by skyper, 3 years ago

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.

in reply to:  9 comment:10 by GerdP, 3 years ago

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 by skyper, 3 years ago

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

comment:12 by skyper, 3 years ago

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

by GerdP, 3 years ago

Attachment: 20624.3.patch added

"Copy server url", also use selected deleted objects

comment:13 by simon04, 3 years ago

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 by GerdP, 3 years ago

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 by GerdP, 3 years ago

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

comment:16 by GerdP, 3 years ago

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.

by GerdP, 3 years ago

Attachment: 20624.with-notes.patch added

My experimental code reg. notes

comment:17 by GerdP, 3 years ago

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

comment:18 by simon04, 3 years ago

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 by simon04, 3 years ago

Keywords: clipboard added

comment:20 by GerdP, 3 years ago

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

in reply to:  20 comment:21 by stoecker, 3 years ago

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 by GerdP, 3 years ago

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

comment:23 by simon04, 3 years ago

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

comment:24 by GerdP, 3 years ago

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. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.