Input Text?
BlitzMax Forums/BlitzMax Programming/Input Text?
| ||
Weird! I have quite an elaborate graphical project going here but no idea how basic TEXT is input. The point I'm at in my game is a typical character create panel where you click attributes to raise, lower, etc. One field of course is the Name: section. The idea is that the player clicks in this field and then types in a name. How do I do this? I can't seem to find any information anywhere. Thanks as usual! -Rob |
| ||
I *think* (not 100% sure, but someone will correct me if I'm talking trash) you'll have to roll your own assuming you're not using MaxGUI. Something like this may give you a starter for ten. http://www.blitzmax.com/codearcs/codearcs.php?code=1379 |
| ||
This example is from my BlitzMax book.. |
| ||
![]() I wrote a fully-featured text field object a little while ago. It uses some different, fancier text-drawing code and it's not very well commented, but I imagine it could still prove helpful as a reference. (You don't want the aforementioned text-drawing code, it's a mess at the moment.) It has copy/paste, undo, shift-selection (and ctrl+a), mouse-selection, completely implemented cursor movement (arrows, ctrl+arrows, etc.), basically everything that a proper textfield should have. https://dl.dropboxusercontent.com/u/10116881/blitz/code/textfield-.bmx https://dl.dropboxusercontent.com/u/10116881/program/textfield/textfield.exe Dependencies: Word wrap: http://www.blitzbasic.com/codearcs/codearcs.php?code=3068 Mouse input handling: http://www.blitzbasic.com/codearcs/codearcs.php?code=3072 Key input handling: http://www.blitzbasic.com/codearcs/codearcs.php?code=3083 char.bmx: I also wrote this so that it could interact with the Windows clipboard, but sometimes it would cause the program to crash and I never resolved it: http://www.blitzbasic.com/codearcs/codearcs.php?code=3073 |
| ||
Thats a neat little text input. Have you thought of adding in scrolling up and down for when text drops off the bottom of the viewing area? |
| ||
I haven't really had any need to do that, but it should be straightforward enough to implement if you wanted to use that code. Just put in a y offset somewhere for drawing and tell it to keep it centered-ish on the cursor. |
| ||
Thank you a lot for all these codes (short and long codes), it's exactly what i was needing and they are very well written. Much better than what i use to write ;) Regards Golomp |