-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
Fix text layer getting deselected after clicking out of Text tool interactive editing #2144
base: master
Are you sure you want to change the base?
Fix text layer getting deselected after clicking out of Text tool interactive editing #2144
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well; thanks for this contribution.
@adamgerhant could you please review this in regards to the introduced ActivePanel code, to make sure it doesn't conflict with your existing implementation of the related concept of the active panel used for showing whether the graph's subnetwork or Layers panel is active? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The active panel is currently being stored in the portfolio message handler. There is no need to store it in the document message handler.
@adamgerhant the text tool code can't access the portfolio message handler. |
Why not just leave the text layer as selected when editing ends? |
I haven't worked much with design tools much, but doesn't keeping text layers selected after editing deviates from standard design tool patterns where edits typically end in deselection. In this implementation the layer while in editing is deselected when clicked anywhere else expect properties panel |
@Sidharth-Singh10 I like where you're going with that thought process, although I believe for consistency with other drawing tools in Graphite, it would be best to keep it selected after clicking out. If you draw with any other tool like Rectangle or Ellipse, you'll notice if you look in the Layers panel, that layer remains selected after finishing drawing it. So it'd be best if the layer remains selected if you click anywhere in the viewport, or anywhere else in the UI, after interactively editing the text. Thanks :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my previous comment for the updated approach, thanks!
editor/src/messages/portfolio/document/document_message_handler.rs
Outdated
Show resolved
Hide resolved
!build |
|
Can I have you add another little improvement to this PR while I'm thinking about it? If the user is editing the interactive text in the viewport, and hits escape, it should delete the entire text layer if escape was pressed when the text was empty. So if a user creates text in the wrong spot but doesn't type anything (or types then deletes it all), escape will delete the layer so it doesn't get invisibly stuck behind. In addition to the escape key, also right clicking somewhere outside the text within the viewport should have the same effect as escape. |
!build |
|
!build |
It looks like Escape is working but right-click isn't for canceling an empty text layer for it to get deleted. Can you please look into making it work when it's empty and the user right-clicks? (Also note that I rebased, so you'll need to pull before continuing to code on it.) |
|
Hey @Keavon, I added an entry for To confirm I was editing the correct location, I commented out the Could you nudge me in the right direction? |
I'll ping @0HyperCube to see if he can answer your question about that. |
The actions that are advertised to the input mapper system don't include the commit text when the text is not being edited: fn actions(&self) -> ActionList {
match self.fsm_state {
TextToolFsmState::Ready => actions!(TextToolMessageDiscriminant;
Interact,
),
TextToolFsmState::Editing => actions!(TextToolMessageDiscriminant;
Interact,
Abort,
CommitText,
),
}
} Any time any mouse button is pressed that is not inside the text input, |
Thanks for pointing this out! |
!build |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
editor/src/messages/tool/tool_messages/text_tool.rs:257
- The check for
has_remove_textbox
should be done before addingDisplayRemoveEditableTextbox
to the responses to avoid redundancy.
let has_remove_textbox = responses.iter().any(|msg| matches!(msg, Message::Frontend(FrontendMessage::DisplayRemoveEditableTextbox)));
editor/src/messages/tool/tool_messages/text_tool.rs:467
- The
set_editing
call should be made after deleting the empty text layer to prevent potential UI issues.
tool_data.set_editing(false, font_cache, responses);
@Sidharth-Singh10 your solution to emulate an escape keypress from the frontend TS code is a hack that works but isn't very clean. Can you please take into account what Hypercube wrote and implement a solution in the backend Rust code? In other words, you need to have something run before the tool state leaves |
a29a3a8
to
61bb542
Compare
61bb542
to
2686957
Compare
!build |
|
Closes #2127
active_panel
field inDocumentMessageHandle
r to track the currently active interface panel.set_editing
fn to verify if the active panel is the Properties Panel, preventing its deselection during edits.Screencast_20241218_015818.online-video-cutter.com.mp4