Getting On-Screen Keyboard "Paste" button to work

I THINK I've got it.  I admit I don't understand the OSK code _at all_.
This commit is contained in:
Bill Kendrick 2024-12-25 10:39:49 -08:00
parent 9103b783ce
commit f9728edd05
3 changed files with 9 additions and 5 deletions

View file

@ -6,14 +6,13 @@ Copyright (c) 2002-2024
Various contributors (see below, and AUTHORS.txt)
https://tuxpaint.org/
2024.December.20 (0.9.35)
2024.December.25 (0.9.35)
* Text & Label Tool Improvements:
-------------------------------
+ WIP It is now possible to paste text from the copy/paste clipboard
into Tux Paint. If text goes beyond the right of the canvas,
a new line is created. If text goes beyond the bottom of the
canvas, the text is truncated there.
- WIP: Add a "paste" button to the On Screen Keyboards
- TODO: Improve word-wrapping (word-based, not character)
- TODO: Mention the feature in documentation
Closes https://sourceforge.net/p/tuxpaint/feature-requests/95/

View file

@ -19,7 +19,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last modified: December 19, 2024
Last modified: December 25, 2024
*/
#include "debug.h"
@ -1900,6 +1900,11 @@ struct osk_keyboard *osk_clicked(on_screen_keyboard *keyboard, int x, int y)
event.text.text[0] = '\b';
event.text.text[1] = '\0';
}
else if (wcsncmp(L"XF86Paste", ks, 9) == 0)
{
event.key.keysym.sym = SDLK_PASTE;
event.text.text[0] = '\0'; // FIXME: Is this okay? -bjk 2024.12.25
}
else if (wcsncmp(L"NoSymbol", ks, 8) == 0)
{
return (keyboard);

View file

@ -3155,7 +3155,7 @@ static void mainloop(void)
update_screen_rect(&r_tools);
}
}
else if ((key == SDLK_v && (mod & KMOD_CTRL)) && !noshortcuts)
else if (((key == SDLK_v && (mod & KMOD_CTRL)) && !noshortcuts) || key == SDLK_PASTE)
{
/* Ctrl-V - Paste */
if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
@ -3220,7 +3220,7 @@ static void mainloop(void)
|| event.key.keysym.sym == SDLK_TAB
|| event.key.keysym.sym == SDLK_LALT || event.key.keysym.sym == SDLK_RALT)))
{
/* Handle key in text tool: */
/* Handle special keys key in text tool: */
if (((cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
&& cursor_x != -1 && cursor_y != -1) || (cur_tool == TOOL_LABEL