Pages: 1
Author Topic: get_string without a dialog  (63,449 Views)
Offline (Unknown gender) Darkstar2

Member
Joined: Jan 2014
Posts: 1,238
View profile
Posted on: February 10, 2014, 05:45:49 AM
I am looking to add interaction in my game, where the user inputs data, however I do not want the pop-up dialog box to appear but only the flashing cursor would appear at an x,y position and allow a user to input text.  In short, it is the get_string without the dialog box.

Something like

get_string(x,y,len,def)

(x,y position to set input cursor, maximum length of str, default value)

Please advise.

Thanks.
Offline (Unknown gender) The 11th plague of Egypt

Member
Joined: Dec 2009
Posts: 274
View profile
Reply #1 Posted on: February 10, 2014, 11:26:29 AM
Add me to the list.
However, that get_string was working as a blocking call, IIRC.
Code execution stopped until the user wrote and pressed OK.
I guess what you want is more like "pick up the text the user wrote in a field", without the waiting part.
textfield.getText();

BTW I'm not even sure that GM's get_string is implemented in Enigma right now.
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #2 Posted on: February 10, 2014, 02:19:10 PM
get_string is implemented, along with get_color and all that Jazz. Darkstar2 if you have the latest version there is the Asynch extension you can enable and use get_string_async which is from Studio and allows the game to continue updating while the user inputs the string, then the Asynchronous Dialog event is triggered when they've entered their response. I can also make you an example that just uses script_thread.

However, I think you may be looking to custom render the input, if that is the case, use keyboard_string, I have written you an example for this.

Hit tab to open the input box, enter a string and then hit enter. This is a simple way of accepting input from a user for a while in GM.
https://www.dropbox.com/s/c0mnfzw10dsffvg/keyboardstring.gm81

There is currently a bug with keyboard_string though where backspace does not clear your last character but adds a new capital 'H' this little piece of code will resolve that until it is fixed, just add it at the very top of the step event.
Code (EDL) Select

if (keyboard_check_pressed(vk_backspace)) {
keyboard_string = string_copy(keyboard_string, 0,
string_length(keyboard_string) - 2);
}
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #3 Posted on: February 10, 2014, 02:24:50 PM
I also made textbox for GM a while ago and did a conversion to ENIGMA, but there was still some bugs I didn't fix so it's not entirely functional and pretty looking. Maybe you guys can check the code and fix that.
https://www.dropbox.com/s/2jv1k4emsh2zxaq/textbox_v5.gmk
It also has things like selecting parts of the text with mouse, inserting, deleting, copy/paste and so on.

I would want to fix it, but I don't have the time right now.

Another example I made just for ENIGMA is here:
https://www.dropbox.com/s/njetsb4ocl54k27/cool_effect.gmk
It's a lot prettier, but a lot simpler (you can only type, nothing more, not even deletion works there, but it's not hard to make).
http://i.imgur.com/4zUYNXG.png

How can you resize images on this board? Classic BBCode ain't working.
Offline (Unknown gender) Darkstar2

Member
Joined: Jan 2014
Posts: 1,238
View profile
Reply #4 Posted on: February 10, 2014, 08:47:15 PM
Thanks, but what I actually need is a direct text entry with cursor, no boxes whatsoever and no dialog boxes.  I would like to handle my own text input area and just have the text input start at whatever area of the room that I point it to.

EXAMPLE, I have a sprite shape on my screen and want the text entry to be done on top of that (superposed), so it's simple, no dialog boxes, no boxes, just the getting keyboard entries input directly from a coordinate, with the flashing cursor.

Quote from: Robert B Colton on February 10, 2014, 02:19:10 PM
get_string is implemented, along with get_color and all that Jazz. Darkstar2 if you have the latest version there is the Asynch extension you can enable and use get_string_async which is from Studio and allows the game to continue updating while the user inputs the string, then the Asynchronous Dialog event is triggered when they've entered their response. I can also make you an example that just uses script_thread.

However, I think you may be looking to custom render the input, if that is the case, use keyboard_string, I have written you an example for this.

Hit tab to open the input box, enter a string and then hit enter. This is a simple way of accepting input from a user for a while in GM.
https://www.dropbox.com/s/c0mnfzw10dsffvg/keyboardstring.gm81

There is currently a bug with keyboard_string though where backspace does not clear your last character but adds a new capital 'H' this little piece of code will resolve that until it is fixed, just add it at the very top of the step event.
Code (EDL) Select

if (keyboard_check_pressed(vk_backspace)) {
keyboard_string = string_copy(keyboard_string, 0,
string_length(keyboard_string) - 2);
}

Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #5 Posted on: February 10, 2014, 08:50:46 PM
Test my example Darkstar2, remove the text box drawing code, it will do just what you want :P
Offline (Unknown gender) Darkstar2

Member
Joined: Jan 2014
Posts: 1,238
View profile
Reply #6 Posted on: February 10, 2014, 08:53:14 PM
Ok will try it later thanks.

About that capital H thing, that's strange..... :D

Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #7 Posted on: February 10, 2014, 09:00:24 PM
Not strange at all the letter 'H' maps to the backspace key.
http://www.physics.udel.edu/~watson/scen103/ascii.html

It's a bug in ENIGMA, ENIGMA is supposed to interpret it ofc as backspace and remove it from keyboard_string global variable like the code I gave you, I'm just extremely busy with LGM development to do it atm.
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #8 Posted on: February 10, 2014, 09:41:29 PM
QuoteThanks, but what I actually need is a direct text entry with cursor, no boxes whatsoever and no dialog boxes.  I would like to handle my own text input area and just have the text input start at whatever area of the room that I point it to.
Both of my examples and the Robert's example already did that. You should probably check them out before posting a reply. :D
Offline (Unknown gender) Darkstar2

Member
Joined: Jan 2014
Posts: 1,238
View profile
Reply #9 Posted on: February 11, 2014, 02:17:02 AM
Quote from: TheExDeus on February 10, 2014, 09:41:29 PM
QuoteThanks, but what I actually need is a direct text entry with cursor, no boxes whatsoever and no dialog boxes.  I would like to handle my own text input area and just have the text input start at whatever area of the room that I point it to.
Both of my examples and the Robert's example already did that. You should probably check them out before posting a reply. :D

lol !  Yeah I saw a rectangle there that's why. :D

Anyhow thanks a lot to everyone, appreciate it ! You have a solution to everything, :D
Offline (Unknown gender) Jimmy_D

Member
Joined: Jan 2014
Posts: 69
View profile
Reply #10 Posted on: February 15, 2014, 04:10:24 AM
See I rest my case not one thing that is not broken or buggy with enigma.

what a weird ass request you should use another program this one is br0ken!
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #11 Posted on: February 15, 2014, 01:24:37 PM
There are some hundred good reasons to implement a custom-rendered widgets library. Ideally, one that uses ENIGMA's own functions, so it's portable. It'd have a lot of strange dependencies, but as long as it listed them in the ey file, it'd be okay. It'd solve your problem, as well as the same problem on consoles and embedded systems.
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #12 Posted on: February 17, 2014, 03:52:31 PM
Back on topic, the backspace issue has been fixed with keyboard_string now. It performs almost exactly the same as GameMaker.
https://github.com/enigma-dev/enigma-dev/pull/644
These are the remaining anomalies.
https://github.com/enigma-dev/enigma-dev/issues/647

Also Josh, not every GUI is a widget library, widgets sounds way too software, there is only an interest in textureable GUI controls like Unity3D, OGRE, or Irrlicht have built in.
http://docs.unity3d.com/Documentation/Components/gui-Basics.html

http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Comparison+of+GUIs
Offline (Unknown gender) The 11th plague of Egypt

Member
Joined: Dec 2009
Posts: 274
View profile
Reply #13 Posted on: February 22, 2014, 03:53:00 PM
Keep that mess that is the Unity "GUI" away from me!

Static methods invoked every frame just to draw a button?!
Need to check that static method every frame to know if that button was clicked?
I'd rather use async events, thanks.
Any other paradigm is way better than what they came up with for Unity.

It's not a surprire that the 3rd party NGUI is selling so well when Unity provides a "GUI" for free.
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #14 Posted on: February 22, 2014, 07:22:43 PM
I meant in comparison to GameMaker, anything is better than draw_button()
Pages: 1