Cross-platform keyboard copy/paste
BlitzMax Forums/BlitzMax Programming/Cross-platform keyboard copy/paste
| ||
This is a two-part question really. The first is: what are the most commonly used keyboard shortcuts for "copy" and "paste" on all three platforms? ctrl-c and ctrl-v for Windows, I believe, but what about Mac and Linux? Second: Is there an available function/library/module that will allow me to paste from the system "clipboard" (text only for now) into my non-GUI BlitzMax program? Specifically, I have a code-entry function and it has been suggested to me that users should be allowed to copy the code from an email and paste it into to code-entry box within the game. This needs to work on all three platforms. I can check for the appropriate keystrokes easily enough (hence, my first question), but how do I pull text data from the system clipboard? |
| ||
on Linux it's generally the same, on Mac, they use Apple+X,C,V I believe. |
| ||
Don't forget CTRL-X, which is Cut. |
| ||
The BlitzMax modifier constant MODIFIER_COMMAND returns MODIFIER_CONTROL on Windows and Linux, and MODIFIER_SYSTEM on Mac, so I always use this (with C, V and X) to provide cross-platform support for copy n' paste. |
| ||
Also don't forget Ctrl-Insert for copy and Shift-Insert for paste under windows... I personally use shift-insert almost exclusively, since it was the only keyboard shortcut that worked in some of the programs that I use all the time... The creators couldn't be bothered to actually add a copy/paste functionality of their own, and even Ctrl-V didn't work -- but the shift-insert windows shortcut still worked like a charm. IIRC those two key combinations do the same under Linux. |
| ||
how do I pull text data from the system clipboard? Via system API calls most probably. Perhaps the various MaxGUI mods are a place to investigate how some of that has been implemented already. |
| ||
On Mac, this looks like a good bet : http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSPasteboard |
| ||
On Win32, there's : http://msdn.microsoft.com/en-us/library/ms649039(VS.85).aspx (see win32textarea.cpp in original MaxGUI for example) |
| ||
On Linux, things get a little hard-core... A basic example : http://www.experts-exchange.com/Programming/Editors_IDEs/C_CPP_CS/Q_22526745.html and also points to the following manual, of which this section mentions clipboard : http://www.sbin.org/doc/Xlib/chapt_12.html ;-) |
| ||
There's also some snippets in the code archives about how to read/write to the clipboard from within Blitz, at least on Windows. |
| ||
Thanks guys...this should get me started. |