Pressing Enter [SOLVED]

Started by Atelier, Sat 08/01/2011 12:16:41

Previous topic - Next topic

Atelier

I swear I've read how to do this somewhere but cannot find it again... how do I simulate a key being pressed? There is text added to an input box, and I'd like enter to be 'pressed' afterwards so the player doesn't have to.

Thanks.

T-Pr

#1
you mean ; you want to press "enter" for twice or more in different events or functions ? if yes , i think it's hard to work it in the same room but you can press enter in different rooms for different functions with : if (cTre.Room == 24)

Atelier

Something like this

Code: ags


function bLook_OnClick(GUIControl *control, MouseButton button)
{
    InputBox.Text = "look";
    //Simulate enter
}

Calin Leafshade

just call the function in the OnActivate event?


Atelier

OnActivate is called only when the player presses enter, which is the problem; I just need to activate the text box with code instead of making the player physically press the button, because it defeats the object of quick commands.

Calin Leafshade

yea, but you can call the function yourself manually

like:

Code: ags

function bLook_OnClick(GUIControl *control, MouseButton button)
{
    InputBox.Text = "look";
    InputBox_OnActivate(InputBox);

}



this function (by default) is TextBox1_OnActivate(GUIControl *control)
so providing you call the function correctly (with a guicontrol or null) you can call it manually like any other function.

Even if you couldnt do this then you could still wrap your logic inside another function and call that instead from both OnActivate and from your simulated event.

Atelier

Ah I see now, thanks Calin ^^

SMF spam blocked by CleanTalk