Clear Data Input Button..?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Clear Data Input Button..?
Hi,
If I wanted to have a button to 'undo' the last input to a field "fld1" how would I say that..?
Also if I wanted a button to 'clear' All inputs - i.e. start again, clear all..?
One more question, is it possible to have the background of a text label only show on a certain trigger then disappear when not required..?
Thanks
If I wanted to have a button to 'undo' the last input to a field "fld1" how would I say that..?
Also if I wanted a button to 'clear' All inputs - i.e. start again, clear all..?
One more question, is it possible to have the background of a text label only show on a certain trigger then disappear when not required..?
Thanks
Re: Clear Data Input Button..?
topcat888,
Could you please provide more extensive explanations of your problems?
1) this is what I am trying to achieve
2) this is what I got so far
3) and this is where I get stuck
That would make it so much easier to answer your questions!
I'll give it a go, I don't know whether my answers are helpful this time.
You can use the undo command to undo the most recent input.
Use
to clear a variable. Replace x with a field reference to clear a field.
I am sure you can script the appearance of a label field and make it's background change. For example, change the backColor of the label field. Maybe you mean something else and want to set the style of the label field to transparent or opaque.
Best regards,
Mark
Could you please provide more extensive explanations of your problems?
1) this is what I am trying to achieve
2) this is what I got so far
3) and this is where I get stuck
That would make it so much easier to answer your questions!
I'll give it a go, I don't know whether my answers are helpful this time.
You can use the undo command to undo the most recent input.
Use
Code: Select all
put empty into x
I am sure you can script the appearance of a label field and make it's background change. For example, change the backColor of the label field. Maybe you mean something else and want to set the style of the label field to transparent or opaque.
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Clear Data Input Button..?
Hi Mark,
Thanks for your reply. The reason this question seems out of context is because it 'was' at the bottom of my 'Moving Numbers' post but received no reply so I started a new post in the hope of getting a reply.!
I am aware of the put empty into x but in this instance it is not applicable because whilst it does remove the last entry, when a new number is entered it does not over write the 'blank space' created by put empty into x, instead it is carried along from field to field which is obviously no good..? In other words the new number does not over write the blank field, the 'blank' is carried along from field 1 to field 2,3,4 and 5 as actual number/entry which is obviously isn't..?
The next question related to to the clearance of 'All' user entered data, in other words a 'Clear All' - 'Start Again' button..?
I will try the 'backColor' to script the colour change of a text field...
Thanks for your help,
Thanks for your reply. The reason this question seems out of context is because it 'was' at the bottom of my 'Moving Numbers' post but received no reply so I started a new post in the hope of getting a reply.!
I am aware of the put empty into x but in this instance it is not applicable because whilst it does remove the last entry, when a new number is entered it does not over write the 'blank space' created by put empty into x, instead it is carried along from field to field which is obviously no good..? In other words the new number does not over write the blank field, the 'blank' is carried along from field 1 to field 2,3,4 and 5 as actual number/entry which is obviously isn't..?
The next question related to to the clearance of 'All' user entered data, in other words a 'Clear All' - 'Start Again' button..?
I will try the 'backColor' to script the colour change of a text field...
Thanks for your help,
Re: Clear Data Input Button..?
TopCat,
if you want to clear several buttons then in a repeat loop you could say put empty into field x.
If I remember then you had 4 fields that are filled from right to left. If you want to have some sort of memory of the last that was pushed out of the leftmost field you could put field 4 into a hidden field 5 that has the advantage that you can easily make a undo by shifting the numbers back from field 5 (the number that was pushed off) into field 4 and so on. Of course you would start with field 2 that goes into field 1 and 3 into field 2 ... you get the idea.
regards
Bernd
if you want to clear several buttons then in a repeat loop you could say put empty into field x.
Code: Select all
on mouseUp
repeat with i = 1 to the number of fields
put empty into field i
end repeat
end mouseUp
regards
Bernd
Re: Clear Data Input Button..?
Hi Bernd,
Thanks for the reply, I hadn't thought of doing it like that, moving all numbers back one, very novel idea... I was thinking that simply the number that was last input (into the first field) could be erased ready to accept a new one..?
If I was to implement your way of doing it, I would use a simple push button to move all number back one field... how would I say that in code..?
Thanks
Thanks for the reply, I hadn't thought of doing it like that, moving all numbers back one, very novel idea... I was thinking that simply the number that was last input (into the first field) could be erased ready to accept a new one..?
If I was to implement your way of doing it, I would use a simple push button to move all number back one field... how would I say that in code..?
Thanks
Re: Clear Data Input Button..?
TopCat,
suppose you have the 5 fields I mentioned, 4 for display and 1 for the 'overflow'
they are named "disp1,disp2,disp3,disp4,disp5" disp1 being the rightmost, accepting the latest user input and pushing older inputs to disp2, disp3 etc.
Now you have shifted the content by one field, you have to catch that the user does not click repeatedly, this would have field disp5 filling up all the other fields.
If not you could just put empty into the field.
regards
Bernd
suppose you have the 5 fields I mentioned, 4 for display and 1 for the 'overflow'
they are named "disp1,disp2,disp3,disp4,disp5" disp1 being the rightmost, accepting the latest user input and pushing older inputs to disp2, disp3 etc.
Code: Select all
on mouseUp
put "disp1,disp2,disp3,disp4,disp5" into tListOfFields
repeat with i = 2 to the number of items of tListOfFields
put field (item i of tListOfFields) into field (item i - 1 of tListOfFields)
end repeat
end mouseUp
in my opinion it all depends on your user interface. You can do it either way. From what I remember when the user clicks it puts the number into what I call field "disp1" if the information in the other fields is still relevant to the user and he might just go back one step then I would move the numbers for the user to have the state "one click before"Thanks for the reply, I hadn't thought of doing it like that, moving all numbers back one, very novel idea... I was thinking that simply the number that was last input (into the first field) could be erased ready to accept a new one..?
If not you could just put empty into the field.
regards
Bernd
Re: Clear Data Input Button..?
Thats the problem with that way, if you put empty into fld1 (the first field to be entered) then when the user presses the new number, instead of the blank field being populated by the new number the 'blank' moves one field to the left (field 2) and the new number is put into field 1... see the problem..? I would still like to have the choice of either of these ways, but this one is not right yet..?If not you could just put empty into the field.
Out of interest is there a way to stop the user 'clicking' past a certain number of back clicks, i.e. after clicking the back button for x numbers of clicks it does nothing..?
Thanks
Re: Clear Data Input Button..?
TopCat,
uUndoCounter is a name you are free to choose as long as it is not a reserved word. By issueing the command you create the custom property. You can access the private property from other objects.
So you could set this property from your undo button and test whether the number is within the range you want. In your script that fills the field in the normal mode you can then reset that counter because now you have something to 'undo' again.
I made a little stack that shows you what I mean.
regards
Bernd
you can do that in different ways. My preferred way would be to make a custom property for the button. It sounds complicated but is just some storage you can attack to every object in Rev. It is persistent i.e. it is stored with the stack. You create one simply by issueing a command like this:Is there a way to stop the user keep clicking past a certain number of back clicks, i.e. after clicking the back button for x numbers of clicks it does nothing..?
Code: Select all
set the uUndoCounter of me to the uUndoCounter of me +1
So you could set this property from your undo button and test whether the number is within the range you want. In your script that fills the field in the normal mode you can then reset that counter because now you have something to 'undo' again.
I made a little stack that shows you what I mean.
regards
Bernd
Re: Clear Data Input Button..?
topcat,
Without knowing your script it is difficult to be more precise, but by now you are an experienced Rev programmer anyways
, so not sweat
regards
Bernd
you can always in your populating script test for a blank field and if the field is bland adjust your populating accordingly.new number the 'blank' moves one field to the left (field 2) and the new number is put into field 1... see the problem..? I would still like to have the choice of either of these ways, but this one is not right yet..?
Code: Select all
if field 1 is empty then
--do the part for the empty field
else
--do the normal part
end if

regards
Bernd
Re: Clear Data Input Button..?
TopCat,
I forgot to mention explicitly that the syntax for properties and also custom properties in Rev is a little different from the normal container syntax.
You say e.g. for setting a backgroundcolor: set the backgroundColor of field 1 to blue
Likewise for a custom property you say: set the uUndoCounter of button 1 to 10
You have to use the set syntax. You can not 'put' anything into a property or custom property.
regards
Bernd
I forgot to mention explicitly that the syntax for properties and also custom properties in Rev is a little different from the normal container syntax.
You say e.g. for setting a backgroundcolor: set the backgroundColor of field 1 to blue
Likewise for a custom property you say: set the uUndoCounter of button 1 to 10
You have to use the set syntax. You can not 'put' anything into a property or custom property.
regards
Bernd
Re: Clear Data Input Button..?
Hi Bernd,
Thankyou for your advise. I have done this so far but it does not work properly:
Can you see anything that is obviously wrong..?
Thanks
Thankyou for your advise. I have done this so far but it does not work properly:
Code: Select all
if the target contains "button" then
put the label of the target into tLabel
if tLabel > 0 and tLabel < 13 then put "L" into field "fld1"
if tLabel > 12 and tLabel < 25 then put "M" into field "fld1"
if tLabel > 24 and tLabel < 37 then put "H" into field "fld1"
else
put field "fld3" into field "fld4"
put field "fld2" into field "fld3"
put field "fld1" into field "fld2"
end if
end if
if the target contains "button" then
put tLabel into field "lastNum1"
else
put field "lastNum17" into field "lastNum18"
put field "lastNum16" into field "lastNum17"
put field "lastNum15" into field "lastNum16"
put field "lastNum14" into field "lastNum15"
put field "lastNum13" into field "lastNum14"
put field "lastNum12" into field "lastNum13"
put field "lastNum11" into field "lastNum12"
put field "lastNum10" into field "lastNum11"
put field "lastNum9" into field "lastNum10"
put field "lastNum8" into field "lastNum9"
put field "lastNum7" into field "lastNum8"
put field "lastNum6" into field "lastNum7"
put field "lastNum5" into field "lastNum6"
put field "lastNum4" into field "lastNum5"
put field "lastNum3" into field "lastNum4"
put field "lastNum2" into field "lastNum3"
put field "lastNum1" into field "lastNum2"
end if
Thanks
Re: Clear Data Input Button..?
Hi topcat,
what exactly do you mean with "does not work properly"? Does it work, but not as exspected, do you get an error, if yes which one etc.
Please, please, please, we need a bit more specific info!
Your script looks OK, but WHERE (button/card/stack) is that handler?
I do not see "on mouseup" or something.
Best
Klaus
what exactly do you mean with "does not work properly"? Does it work, but not as exspected, do you get an error, if yes which one etc.
Please, please, please, we need a bit more specific info!
Your script looks OK, but WHERE (button/card/stack) is that handler?
I do not see "on mouseup" or something.
Best
Klaus
Re: Clear Data Input Button..?
TopCat,
Please explain what the code is supposed to do. What should happen when? I don't know the logic of your stack and there is more then one source of error. What do you expect and what happens instead?
regards
Bernd
Please explain what the code is supposed to do. What should happen when? I don't know the logic of your stack and there is more then one source of error. What do you expect and what happens instead?
regards
Bernd
Re: Clear Data Input Button..?
Hi
Sorry, the problem is that the clear last number now works perfectly (using Bernd code)
But there is a problem when you press a another button (to enter a new number into field 1) it duplicates the new number placing it in field 2 at the same time, every time...
This is all the code:
Thanks
Sorry, the problem is that the clear last number now works perfectly (using Bernd code)
Code: Select all
if field 1 is empty then
--do the part for the empty field
else
--do the normal part
end if
This is all the code:
Code: Select all
on mouseup
if the target contains "button" then
put the label of the target into tLabel
if tLabel = 0 then put "Z" into field "fld1"
if tLabel > 0 and tLabel < 13 then put "L" into field "fld1"
if tLabel > 12 and tLabel < 25 then put "M" into field "fld1"
if tLabel > 24 and tLabel < 37 then put "H" into field "fld1"
else
put field "fld3" into field "fld4"
put field "fld2" into field "fld3"
put field "fld1" into field "fld2"
end if
end if
if the target contains "button" then
put field "lastNum17" into field "lastNum18"
put field "lastNum16" into field "lastNum17"
put field "lastNum15" into field "lastNum16"
put field "lastNum14" into field "lastNum15"
put field "lastNum13" into field "lastNum14"
put field "lastNum12" into field "lastNum13"
put field "lastNum11" into field "lastNum12"
put field "lastNum10" into field "lastNum11"
put field "lastNum9" into field "lastNum10"
put field "lastNum8" into field "lastNum9"
put field "lastNum7" into field "lastNum8"
put field "lastNum6" into field "lastNum7"
put field "lastNum5" into field "lastNum6"
put field "lastNum4" into field "lastNum5"
put field "lastNum3" into field "lastNum4"
put field "lastNum2" into field "lastNum3"
put field "lastNum1" into field "lastNum2"
else
put tLabel into field "lastNum1"
end if
end mouseUp
Re: Clear Data Input Button..?
TopCat,
I give it a try:
if you have problems with this tell us about it. To me it is still not completely clear what you want but here it goes.
regards
Bernd
I give it a try:
Code: Select all
on mouseup
if the target contains "button" then
put the label of the target into tLabel
-- test for your range of interest
-- between 0 and 36 and only then do the following
if tLabel >-1 and tLabel < 37 then
-- do your field shuffling before putting
-- the new value into "fld1" otherwise the new value would
-- be shifted to fld2 every time
put field "fld3" into field "fld4"
put field "fld2" into field "fld3"
put field "fld1" into field "fld2"
if tLabel = 0 then put "Z" into field "fld1"
if tLabel > 0 and tLabel < 13 then put "L" into field "fld1"
if tLabel > 12 and tLabel < 25 then put "M" into field "fld1"
if tLabel > 24 and tLabel < 37 then put "H" into field "fld1"
put field "lastNum17" into field "lastNum18"
put field "lastNum16" into field "lastNum17"
put field "lastNum15" into field "lastNum16"
put field "lastNum14" into field "lastNum15"
put field "lastNum13" into field "lastNum14"
put field "lastNum12" into field "lastNum13"
put field "lastNum11" into field "lastNum12"
put field "lastNum10" into field "lastNum11"
put field "lastNum9" into field "lastNum10"
put field "lastNum8" into field "lastNum9"
put field "lastNum7" into field "lastNum8"
put field "lastNum6" into field "lastNum7"
put field "lastNum5" into field "lastNum6"
put field "lastNum4" into field "lastNum5"
put field "lastNum3" into field "lastNum4"
put field "lastNum2" into field "lastNum3"
put field "lastNum1" into field "lastNum2"
put tLabel into field "lastNum1"
else
--
-- if you have anything that should happen if
-- tLabel outside of 0 .... 36 then insert it here
-- or delete the else part
end if
end mouseUp
regards
Bernd