MODULE: TextField v1.2.0

Started by Snarky, Wed 28/03/2018 15:39:51

Previous topic - Next topic

Snarky

This is a quick little module I made for the AGS Awards client. It provides one-line text input fields, as a replacement for the AGS TextInput control.

Ways in which TextField is better than TextInput:
-It has a blinking text cursor
-You can position the cursor anywhere in the text (using mouse or arrow keys), and edit at that point
-It has a notion of focus, so that you can have multiple TextFields displayed without all the text being entered into all the fields
-You can define a max string length the field will accept
-You can make the border partially transparent
-You can add more advanced logic to it, e.g. to only accept certain character types, or to *** out the display of the text

Ways in which TextField is worse than TextInput:
-It's implemented in script, so on slow computers or in a resource-intensive game it could be less responsive than TextInput
-You have to do a little bit of setup to make it work
-You can't link the OnActivate event, so it's a little more complicated to respond when the player presses Return/Enter

The TextField module is available on Github.

Download TextField v1.2.0

You can also try it out in a demo game for the Clipboard plugin:

Download Clipboard Demo

Changelog:
1.2.0
- Fixes crash if TextField initialized with non-empty String
- Adds support for Clipboard plugin

1.1.0
- Initial release
- Fixes poor SHIFT-key detection

1.0.0
- Unreleased (used in AGS Awards 2017 client)

selmiak

nice. What I really missed during the awards ceremony was copy+paste. Is it possible to implement this?

Snarky

#2
It would be pretty easy to do copy-paste between different text fields within an AGS game, but presumably you mean copy-paste from other applications.

That would require a plugin, in order to access the Windows clipboard. I have looked into it a tiny bit, and it's probably not very hard if you know your way around the APIs and libraries and build processes, but... I don't.

See thread here: http://www.adventuregamestudio.co.uk/forums/index.php?topic=55797.0

arj0n

Haven't tested this yet, but it looks like this could be very useful for textparser games. Thanx for making this!

Snarky

Quote from: selmiak on Wed 28/03/2018 17:19:03
nice. What I really missed during the awards ceremony was copy+paste. Is it possible to implement this?
Quote from: Snarky on Wed 28/03/2018 17:42:57
That would require a plugin, in order to access the Windows clipboard. I have looked into it a tiny bit, and it's probably not very hard if you know your way around the APIs and libraries and build processes, but... I don't.

I decided to go ahead and figure it out, and here's a plugin to do it. This module has been updated with support for the plugin, although because I haven't implemented selection, Ctrl-C will copy the entire text of the field.

Gurok

Quote from: Snarky on Fri 30/03/2018 15:41:18
Thanks. Sure, undo/history would be useful to have, but it wouldn't be part of the plugin, but rather something you implement in your game logic. I'll think about adding it to the TextField module.

Windows Forms stuff gives you one level of undo built into the control from memory. It might be nice to provide that, then let people implement their own if they need to.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Snarky

#6
It's something to think about for the TextField module. In that case I'd almost certainly make the size of the history buffer (how many levels of undo you can backtrack) configurable.

selmiak

that was fast (and hopefully easy enough). Thanks snarky  :-D

Monsieur OUXX

Snarky, if you could extend this to multiple lines, I'd be eternally grateful to you.
Also I'd really encourage you to implement highlight and simple copy/paste (data stays within AGS). You could probably get some inspiration about mouse-control and highlight from my (almost working but eternally slightly broken) module, TextArea.

I realy need a text area component, but I've never managed to release one that's bug free.
 

SMF spam blocked by CleanTalk