Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Text Fields - No enter
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Pickles




PostPosted: Wed May 12, 2004 2:57 pm   Post subject: Text Fields - No enter

Im using a TextField and GUI.GetSliderValue to set the sliders value to that of the number inputted in the text field, but in order for the sliders value to be set the user has to press enter to input the text, is there a way to make it so you get the Sliders value after each individual number without having to hit enter?
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Wed May 12, 2004 3:44 pm   Post subject: (No subject)

Hmm...
Text fields have sliders? I know text boxes do...

Try (in your GUI.GetProcessEvent loop) to check for the length of the text within the text field/box. If it is of a length longer than in the last loop, then get the slider value.
Pickles




PostPosted: Wed May 12, 2004 3:56 pm   Post subject: ..

I wasnt really to clear:

I'm making a Gorillas game where they throw bananas at eachother.
I have a slider for Velocity, but also a text field that they can input their velocity into if they have an exact number they want. But if you enter the number in the text field you have to press enter before it sets the slider to that value. Basically i wnat it so you dont even need to press enter, it just moves along with your typing, for example if someone were to say want 175 power. the slider would go to 1 then 17 then 175 as you type it in. Right now youd have to type in 175 then hit enter for it to move
Delos




PostPosted: Wed May 12, 2004 4:05 pm   Post subject: (No subject)

Try this (WARNING! I'VE ADDED STUFF IN HERE THAT YOU NEED TO FIX Twisted Evil ):

code:

import GUI

var textF : int
var temp : string := ""
var power : int := 0

proc tF (text : string)
    GUI.SetActive (textF)
    GUI.SetSelection (textF, 0, 0)
end tF

textF := GUI.CreateTextField (100, 100, 90, "", tF)

loop
    exit when GUI.ProcessEvent
    if length (GUI.GetText (textF)) > 0 then
        temp := GUI.GetText (textF)
        power := strint (temp)
        locate (1,1)
        put power
    end if
end loop



Of course this has its limitations...you need to find 'em and fix 'em. From here, whenever you get a new value of 'power', just change the slider value to that.
Pickles




PostPosted: Wed May 12, 2004 6:27 pm   Post subject: ..

Beauty, thanks , thats exactly what i was looking for, and if i cant fix it god help us all..


feel free to have a few of my measly bits
Pickles




PostPosted: Thu May 13, 2004 7:20 pm   Post subject: ..

alrighty, right now it goes backwards as in if you wanted 45 you have to type in the 5 then the 4. this is because the cursor jumps back to the start. IS there a simple way to fix this, ive been trying some stuff such as recursion but i havent been able to get it. You don't have to give me the code as to how to do it, but just steer me in the right direction. Smile
Delos




PostPosted: Thu May 13, 2004 8:36 pm   Post subject: (No subject)

I'm not sure if I understand what you're saying...using the ^ code, there is no 'jumping back to the beginning' by the cursor...

Post your code perhaps?
Pickles




PostPosted: Fri May 14, 2004 8:53 pm   Post subject: ..

shes not really commented all that greatly and the variables are hard to follow basically cause i just picked random numbers
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Fri May 14, 2004 9:02 pm   Post subject: (No subject)

Lemme rephrase that...

post problematic code...

Sheesh! 900+ lines! And I had to edit it just so that it would run! (I don't have the folder "Craig Final/..." on my computer...sorry.
Pickles




PostPosted: Sun May 16, 2004 1:17 pm   Post subject: ..

alright i thought i had it but i didnt. I cant seem to make it so you can use both the textfield and slider for choosing. i can only make it do one or the other.

The GUI.SetText in the slider procedure lets you use the slider, but if you want to let the textfield work you need to take that out, than the slider wont slide. I want to make it so you can use them both. but cant figure it out



VelocityProblematic.t
 Description:
Bleh

Download
 Filename:  VelocityProblematic.t
 Filesize:  1.37 KB
 Downloaded:  208 Time(s)

Pickles




PostPosted: Sun May 16, 2004 8:08 pm   Post subject: ..

bah ill give it a bump once, then just let it die
Delos




PostPosted: Sun May 16, 2004 8:31 pm   Post subject: (No subject)

Dude...your proggies are really starting to make my life difficult!

I just spent 10 mins trying to figure it out...only to find that the error was a simple little bug...meh!

Ah well, it's fixed now.

Here's the changes you'll need:
- don't include 'offscreenonly' in your GUI progs...you probably put that there due to force of habit.
- add this line after you check for the length of 'velocityTextBox' (which is really a text field!) being greater than 0 :
code:

        if GUI.GetText (velocityTextBox) not= temp then
        % This makes sure that it only updates as necassay...will get rid
% of all that irritating flashing.

- now for the problem code:

in proc 'SetVeloc', you have a line that reads:
GUI.SetText (velocityTextBox, valuestring)
This means that each time the Slider is looked at, it will reset the text in the text field...this means repositioning the cursor to the beginning of the text field.
Bahleted!

So there you have it.

Go home and fix it...then have another 2 hour lunch.
Pickles




PostPosted: Sun May 16, 2004 10:41 pm   Post subject: ...

The offscreenonly is in there because this was part of my main program, so when i took all the useless junk out and just forgot to take this out.

I want the text field to display the current velocity, like if there were just to use the slider it would show up in the text field, their selection or else they can just type in what they want, Without the SetText it doesnt show up in the textfield but with it it messes it up its quite the quandry.. hmm

thanks for all your help by the way, youve been great
Delos




PostPosted: Mon May 17, 2004 12:05 pm   Post subject: (No subject)

[sigh]

Come on! I'm going to tell you this...but you should have figured it out by now! Naughty
Just do the same thing that was done w/ the text field...check to see if the current value is different from the stored value.

Specifically in the slider proc:

code:

    if GUI.GetSliderValue (velocitySlider) not= (power) then
        GUI.SetText (velocityTextBox, valuestring)
    end if


Try that. (Don't forget the other edits from the last few posts!)
Pickles




PostPosted: Mon May 17, 2004 2:53 pm   Post subject: ..

yeah i feel like an idiot. Thx, youve done alot, more then you should have had to. blasted.

+20 BITS, all i have, wish i coulda given you more
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 15 Posts ]
Jump to:   


Style:  
Search: