Skip to content

Add Ctrl+X (cut) command and numpad navigation to text composition #23720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Feb 21, 2025
Merged

Add Ctrl+X (cut) command and numpad navigation to text composition #23720

merged 14 commits into from
Feb 21, 2025

Conversation

matheusvb3
Copy link
Contributor

@matheusvb3 matheusvb3 commented Jan 27, 2025

Ctrl+X will copy the text and clear the text box (up until this point it appears Clear was completely unused in this file).

I also renamed KEYBOARD_PRIMARY_MODIFIER to KB_PRIMARY_MODIFIER to make it a little less verbose. From what I can tell, it's not actually used in UiContext.cpp, but I updated it there as well just in case.

@AaronVanGeffen
Copy link
Member

AaronVanGeffen commented Jan 27, 2025

Ctrl+Up will send the caret to the beginning, Ctrl+Down will send it to the end

This feels a bit illogical to me. Typically, these shortcuts are used to navigate between fields. It seems what you're looking for is implementing [Home] and [End] key behaviour, no?

CI is failing because STR_NONE has recently been renamed to kStringIdNone.

@matheusvb3
Copy link
Contributor Author

matheusvb3 commented Jan 27, 2025

Yes, Home and End sends the caret to the beginning and end of the current line but I'm a little more used to Ctrl+Up/Down to send the caret back and forth. Normally those are used to send it to the beginning of the next/previous paragraph, but since in RCT it's a single line text input they serve the same functions as Home and End, which is also common behavior. You can try it in inspect element, if you begin editing a random line of code and use these combinations it'll send the caret to the beginning/end of the line. There are some other software where they're used for switching between different UI elements (and in Firefox at least it serves as zoom in/out if the focus is not currently in a text field), but using them to move the caret is not exactly unusual.

CI is failing because STR_NONE has recently been renamed to kStringIdNone.

Got it. 🙏

Edit: Oh wait, should I change that? I misunderstood what you meant at first 😅

@ZehMatt
Copy link
Member

ZehMatt commented Jan 27, 2025

I think it would be better if those things were just actual shortcuts which the user can configure to his choice. I don't mind it having it default to Ctrl+Up/Down but it shouldn't be hardcoded when we have a system to manage shortcuts.

@matheusvb3
Copy link
Contributor Author

I've been thinking about this and I feel more and more the Ctrl+up/down shortcuts aren't that good of an idea in the end... In Firefox, if I click to edit this issue's title and use them they work fine, but if I try them in the search/address bar they already don't work. Honestly I was under the impression these combinations were universal, like Ctrl+C and Ctrl+V, but now I'm seeing they're actually very inconsistent, I just ended up growing very used to them while browsing with Firefox. I'm against adding making this remapable because we already have Home and End (I'm just not accustomed to using them lol), plus no other text box commands are remapable. I think I'll take them out and leave only the cut command.

@matheusvb3 matheusvb3 changed the title Add Ctrl+Up, Ctrl+Down and Ctrl+X (cut) commands to text composition window Add Ctrl+X (cut) command to text composition Jan 30, 2025
@tupaschoal tupaschoal requested a review from ZehMatt January 31, 2025 23:56
Copy link
Member

@ZehMatt ZehMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems alright, in the future its best to have renames in separate commits so its easier to see where the logical changes are.

@matheusvb3
Copy link
Contributor Author

in the future its best to have renames in separate commits so its easier to see where the logical changes are

Just to be sure, you mean making separate PRs? I was under the impression that blame just gave the PR where a certain line was changed, not the actual commit

@ZehMatt
Copy link
Member

ZehMatt commented Feb 1, 2025

in the future its best to have renames in separate commits so its easier to see where the logical changes are

Just to be sure, you mean making separate PRs? I was under the impression that blame just gave the PR where a certain line was changed, not the actual commit

No, not a separate PR but separate commits, first commit could be "Implement X", second commit could be "Rename variables", it makes it easier to review code if we can just look at each commit and not the final resulting changes.

@matheusvb3
Copy link
Contributor Author

matheusvb3 commented Feb 3, 2025

@ZehMatt I know you've already reviewed this but I've been thinking of adding the numpad Delete key to the list of commands, so pressing it will have the same function as the already existing Delete. For some reason that idea didn't come to me until now. Would that be OK for you?

@matheusvb3 matheusvb3 requested a review from ZehMatt February 4, 2025 02:22
@ZehMatt ZehMatt added the squash merge A PR that should be squashed on merge. label Feb 4, 2025
@ZehMatt
Copy link
Member

ZehMatt commented Feb 4, 2025

@ZehMatt I know you've already reviewed this but I've been thinking of adding the numpad Delete key to the list of commands, so pressing it will have the same function as the already existing Delete. For some reason that idea didn't come to me until now. Would that be OK for you?

You did it before I could answer, I'm not opposed of having the functionality but it would have been better for a separate PR to handle the numpad keys for navigation. Anyway, there should be some testing to make sure it works on all platforms as expected.

@matheusvb3 matheusvb3 changed the title Add Ctrl+X (cut) command to text composition Add Ctrl+X (cut) command and numpad navigation to text composition Feb 6, 2025
@ZehMatt ZehMatt added the testing required PR needs to be tested before it is merged. label Feb 11, 2025
Copy link
Member

@AaronVanGeffen AaronVanGeffen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected on macOS 👍

Copy link
Member

@Gymnasiast Gymnasiast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cutting works as expected on Linux.

I have specifically not looked at the code or the discussion.

@ZehMatt
Copy link
Member

ZehMatt commented Feb 14, 2025

I think a changelog entry is also in order then its ready to go.

@ZehMatt ZehMatt added the changelog This issue/PR deserves a changelog entry. label Feb 14, 2025
@matheusvb3
Copy link
Contributor Author

@AaronVanGeffen Is this good? If so, I'll add a changelog entry and I think it's good to go, right?

@AaronVanGeffen AaronVanGeffen enabled auto-merge (squash) February 21, 2025 13:32
@AaronVanGeffen AaronVanGeffen added this to the v0.4.20 milestone Feb 21, 2025
@AaronVanGeffen AaronVanGeffen merged commit a62562d into OpenRCT2:develop Feb 21, 2025
22 checks passed
@matheusvb3 matheusvb3 deleted the text-compos-additions branch February 21, 2025 14:12
Gymnasiast added a commit to Gymnasiast/OpenRCT2 that referenced this pull request Feb 25, 2025
- Feature: [OpenRCT2#22905] Add diagonal downward-inclined brakes to hybrid coaster and single rail coaster.
- Feature: [OpenRCT2#23759] Add see-through option to the “Cut-away View“.
- Improved: [OpenRCT2#23677] Building new ride track now inherits the colour scheme from the previous piece.
- Improved: [OpenRCT2#23720] Text fields now allow cutting to clipboard (Ctrl+X) in addition to copy and paste.
- Improved: [OpenRCT2#23874] The load/save file browser window now uses icons for its action buttons.
- Improved: [OpenRCT2#23875] Rides forbidden to be modified or destroyed can now be edited with the All destructible cheat.
- Improved: [OpenRCT2#23879] Unique weather icons for snow, heavy snow and blizzard.
- Fix: [OpenRCT2#1972, OpenRCT2#11679] Vehicles passing by toilets can cause them to glitch (original bug).
- Fix: [OpenRCT2#9999, OpenRCT2#10000, OpenRCT2#10001, OpenRCT2#10002, OpenRCT2#10003] Truncated scenario strings when using Catalan, Czech, Japanese, Polish or Russian.
- Fix: [OpenRCT2#14486] Guests will fall through upwards sloped paths when making their way through a park entrance or ride exit (original bug).
- Fix: [OpenRCT2#15826, OpenRCT2#23835] Wooden Roller Coaster steep turn supports glitch when train goes over them (original bug).
- Fix: [OpenRCT2#16357] Chairlift station covers draw incorrectly.
- Fix: [OpenRCT2#16657] Mine Ride right S-bend uses Mini Roller Coaster sprite (original bug).
- Fix: [OpenRCT2#18376] Ghost train gentle to flat track is not visible in tunnels.
- Fix: [OpenRCT2#18389] Gentle sloped track pieces are not visible in low clearance height tunnels (original bug).
- Fix: [OpenRCT2#18423] Underground Mini Golf holes can draw over land edges (original bug).
- Fix: [OpenRCT2#18433] CJK TrueType fonts cannot be located when font names are translated by the OS.
- Fix: [OpenRCT2#18436] Scenery on the same tile as steep to vertical track can draw over the track (original bug).
- Fix: [OpenRCT2#18711] Park entrances with their sides underground can cause glitching.
- Fix: [OpenRCT2#20848] Junior Roller Coaster booster track does not draw correctly in tunnels.
- Fix: [OpenRCT2#20948] Incorrect diagonal brakes supports on the Giga Coaster, Looping Roller Coaster and Wooden Roller Coaster.
- Fix: [OpenRCT2#21768] Dirty blocks debug overlay is rendered incorrectly on high DPI screens.
- Fix: [OpenRCT2#22229] Opening a park save file from a newer version of OpenRCT2 yields an unhelpful error message.
- Fix: [OpenRCT2#22617] Sloped Wooden and Side-Friction supports draw out of order when built directly above diagonal track pieces (original bug).
- Fix: [OpenRCT2#22620] Mine Train Coaster trains glitch on large banked turns.
- Fix: [OpenRCT2#23522] Diagonal sloped Steeplechase supports have glitched sprites at the base.
- Fix: [OpenRCT2#23580] Table header labels may overlap if the window is made very small.
- Fix: [OpenRCT2#23641] Steep to flat track is not drawn correctly in tunnels (original bug).
- Fix: [OpenRCT2#23795] Looping Roller Coaster vertical loop supports are drawn incorrectly.
- Fix: [OpenRCT2#23797] 3D Text cut off too early on multi-line signs.
- Fix: [OpenRCT2#23809] Trains glitch on Bobsleigh Coaster small helixes.
- Fix: [OpenRCT2#23811] Land edges glitch when vehicles go through gentle to flat tunnels.
- Fix: [OpenRCT2#23814] Scenarios not indexed on first start.
- Fix: [OpenRCT2#23818] Spinning tunnels can draw over sloped terrain in front of them.
- Fix: [OpenRCT2#23828] Vehicles passing by station entrances and exits can cause them to glitch (original bug).
- Fix: [OpenRCT2#23831] Hybrid Coaster large gentle banked right turns glitch when diagonal track is above them.
- Fix: [OpenRCT2#23832] Hybrid Coaster large gentle banked left turns supports glitch as train passes.
- Fix: [OpenRCT2#23836] Adjacent track can draw over large turns (original bug).
- Fix: [OpenRCT2#23858] LSM launched lift hill has a misaligned sprite.
CorySanin added a commit to CorySanin/OpenRCT2 that referenced this pull request Jun 22, 2025
- Feature: [OpenRCT2#22905] Add diagonal downward-inclined brakes to hybrid coaster and single rail coaster.
- Feature: [OpenRCT2#23759] Add see-through option to the “Cut-away View“.
- Improved: [OpenRCT2#23677] Building new ride track now inherits the colour scheme from the previous piece.
- Improved: [OpenRCT2#23720] Text fields now allow cutting to clipboard (Ctrl+X) in addition to copy and paste.
- Improved: [OpenRCT2#23874] The load/save file browser window now uses icons for its action buttons.
- Improved: [OpenRCT2#23875] Rides forbidden to be modified or destroyed can now be edited with the All destructible cheat.
- Improved: [OpenRCT2#23879] Unique weather icons for snow, heavy snow and blizzard.
- Fix: [OpenRCT2#1972, OpenRCT2#11679] Vehicles passing by toilets can cause them to glitch (original bug).
- Fix: [OpenRCT2#9999, OpenRCT2#10000, OpenRCT2#10001, OpenRCT2#10002, OpenRCT2#10003] Truncated scenario strings when using Catalan, Czech, Japanese, Polish or Russian.
- Fix: [OpenRCT2#14486] Guests will fall through upwards sloped paths when making their way through a park entrance or ride exit (original bug).
- Fix: [OpenRCT2#15826, OpenRCT2#23835] Wooden Roller Coaster steep turn supports glitch when train goes over them (original bug).
- Fix: [OpenRCT2#16357] Chairlift station covers draw incorrectly.
- Fix: [OpenRCT2#16657] Mine Ride right S-bend uses Mini Roller Coaster sprite (original bug).
- Fix: [OpenRCT2#18376] Ghost train gentle to flat track is not visible in tunnels.
- Fix: [OpenRCT2#18389] Gentle sloped track pieces are not visible in low clearance height tunnels (original bug).
- Fix: [OpenRCT2#18423] Underground Mini Golf holes can draw over land edges (original bug).
- Fix: [OpenRCT2#18433] CJK TrueType fonts cannot be located when font names are translated by the OS.
- Fix: [OpenRCT2#18436] Scenery on the same tile as steep to vertical track can draw over the track (original bug).
- Fix: [OpenRCT2#18711] Park entrances with their sides underground can cause glitching.
- Fix: [OpenRCT2#20848] Junior Roller Coaster booster track does not draw correctly in tunnels.
- Fix: [OpenRCT2#20948] Incorrect diagonal brakes supports on the Giga Coaster, Looping Roller Coaster and Wooden Roller Coaster.
- Fix: [OpenRCT2#21768] Dirty blocks debug overlay is rendered incorrectly on high DPI screens.
- Fix: [OpenRCT2#22229] Opening a park save file from a newer version of OpenRCT2 yields an unhelpful error message.
- Fix: [OpenRCT2#22617] Sloped Wooden and Side-Friction supports draw out of order when built directly above diagonal track pieces (original bug).
- Fix: [OpenRCT2#22620] Mine Train Coaster trains glitch on large banked turns.
- Fix: [OpenRCT2#23522] Diagonal sloped Steeplechase supports have glitched sprites at the base.
- Fix: [OpenRCT2#23580] Table header labels may overlap if the window is made very small.
- Fix: [OpenRCT2#23641] Steep to flat track is not drawn correctly in tunnels (original bug).
- Fix: [OpenRCT2#23795] Looping Roller Coaster vertical loop supports are drawn incorrectly.
- Fix: [OpenRCT2#23797] 3D Text cut off too early on multi-line signs.
- Fix: [OpenRCT2#23809] Trains glitch on Bobsleigh Coaster small helixes.
- Fix: [OpenRCT2#23811] Land edges glitch when vehicles go through gentle to flat tunnels.
- Fix: [OpenRCT2#23814] Scenarios not indexed on first start.
- Fix: [OpenRCT2#23818] Spinning tunnels can draw over sloped terrain in front of them.
- Fix: [OpenRCT2#23828] Vehicles passing by station entrances and exits can cause them to glitch (original bug).
- Fix: [OpenRCT2#23831] Hybrid Coaster large gentle banked right turns glitch when diagonal track is above them.
- Fix: [OpenRCT2#23832] Hybrid Coaster large gentle banked left turns supports glitch as train passes.
- Fix: [OpenRCT2#23836] Adjacent track can draw over large turns (original bug).
- Fix: [OpenRCT2#23858] LSM launched lift hill has a misaligned sprite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog This issue/PR deserves a changelog entry. squash merge A PR that should be squashed on merge. testing required PR needs to be tested before it is merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants