Skip to content

Fix behaviour switching from DefaultTool to text tool and make text tool select all text by default

This fixes the behaviour of double-clicking or pressing Enter on a text shape to edit it, and make it easier for users to edit text on newly-created text shapes.

The tool switching fix for DefaultTool is more of a workaround to avoid triggering the recursion guard, instead of fixing the underlying issue that can cause KisInputManager to unintentionally resend an event:

The original event is handled by KisShortcutMatcher from KisInputManager, which then goes through KisToolInvocationAction and KisToolProxy to eventually reach DefaultTool. When the tool calls KoToolManager::switchToolRequested directly, it eventually calls KisShortcutMatcher::lostFocusEvent and KisShortcutMatcher::toolHasBeenActivated, both of which triggers the recursion guard. KisInputManager then thinks the event hasn't been handled and calls processUnhandledEvent, which sends the event to KisToolProxy for a second time. Observable effects include: double- clicking a text shape causes all text to be selected (by mouseTripleClickEvent), or pressing Enter on a text shape causes an unwanted newline to be inserted immediately.

Test Plan

  • In DefaultTool, double-click on a text shape.
  • In DefaultTool, press Enter on a text shape.
  • In the text tool, create a new text shape.

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.

Reminder: the reviewer is responsible for merging the patch, this is to ensure at the least two people can build the patch. In case a patch breaks the build, both the author and the reviewer should be contacted to fix the build. If this is not possible, the commits shall be reverted, and a notification with the reasoning and any relevant logs shall be sent to the mailing list, kimageshop@kde.org.

Merge request reports

Loading