event handler questions
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
event handler questions
Hi
I'm a new Rev user, I've had media edition for about a week
For my first project, I've been trying to develop a form to convert distances
I want to be able to change kilometers to miles and miles into kilometers
I have a text entry field for the user to input a number, a push button to convert the number and a text field where I would like the result displayed
I'd like for the input to be a variable I can use in the event handler for the push button
ex. set it to dMiles
then have a formula for the conversion and output it in the second text box
I'd appreciate any pointers or example scripts
thanks
I'm a new Rev user, I've had media edition for about a week
For my first project, I've been trying to develop a form to convert distances
I want to be able to change kilometers to miles and miles into kilometers
I have a text entry field for the user to input a number, a push button to convert the number and a text field where I would like the result displayed
I'd like for the input to be a variable I can use in the event handler for the push button
ex. set it to dMiles
then have a formula for the conversion and output it in the second text box
I'd appreciate any pointers or example scripts
thanks
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Contact:
If you have a function like:
then you can do this:
In fact, you don't need to put the miles field into a variable, you can do this:
Hope this helps,
Mark
Code: Select all
function milesToKilometres tMiles
return tMiles * 1.6
end milesToKilometres
Code: Select all
on mouseUp
put fld "miles" into tDistance
put milesToKilometres(tDistance) into fld "kilometres"
end mouseUp
Code: Select all
on mouseUp
put milesToKilometres(fld "miles") into fld "kilometres"
end mouseUp
Mark
got it working
Hi Mark
thanks so much for the help
I've got it working
next I'm going to try to create two more scripts, one to reset or clear the fields and one to close the form so, it will be two more buttons with mouseup handlers
best
Clint
[/img]
thanks so much for the help
I've got it working
next I'm going to try to create two more scripts, one to reset or clear the fields and one to close the form so, it will be two more buttons with mouseup handlers
best
Clint
[/img]
code for event handlers
Hi all
I could use a few more pointers for my event handlers
what is the command to close or unload a form?
I have a button to Close
similarly, I'd be interested to learn the command to reset all the text boxes to blank based on a mouseup event
is there a good place in the dictionary or documentation to look for these sorts of commands, as I work on learning the syntax
thanks
Clint
I could use a few more pointers for my event handlers
what is the command to close or unload a form?
I have a button to Close
similarly, I'd be interested to learn the command to reset all the text boxes to blank based on a mouseup event
is there a good place in the dictionary or documentation to look for these sorts of commands, as I work on learning the syntax
thanks
Clint
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Hi Clint,
The preOpenCard event will be sent to your card just before it is opened, allowing you to call your own 'ResetForm' command - which you can then reuse from a 'Reset' button, keeping the form reset code tidy and in a single spot.
Your best bet is to go through the contents of the Revolution Resource Center (there's a button in the toolbar if you're running Revolution 3.0) and take it from there. And of course you're always welcome here to ask questions
HTH,
Jan Schenkel
Set the script of your "Close" button towhat is the command to close or unload a form?
I have a button to Close
Code: Select all
on mouseUp
answer "Are you sure you want to close this form?" with "OK" or "Cancel"
if it is "OK" then close this stack
end mouseUp
There is no such command, really - but it's pretty easy to roll your own reset routine, by adding something like this to your card scriptsimilarly, I'd be interested to learn the command to reset all the text boxes to blank based on a mouseup event
Code: Select all
on preOpenCard
ResetForm
end preOpenCard
command ResetForm
put 0 into field "miles"
put 0 into field "kilometres"
end ResetForm
The tricky part about documentation is that it's never quite tailored to every person - some people are just starting out with programming in general, while others are coming in from Visual Basic or dabbled with Delphi in the past.is there a good place in the dictionary or documentation to look for these sorts of commands, as I work on learning the syntax
Your best bet is to go through the contents of the Revolution Resource Center (there's a button in the toolbar if you're running Revolution 3.0) and take it from there. And of course you're always welcome here to ask questions

HTH,
Jan Schenkel
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: code for event handlers
Hi Clint ~Clint wrote: ...I'd be interested to learn the command to reset all the text boxes to blank based on a mouseup event
I'd just add to Jan's excellent advise...
If you wish a field to be "blank" and have no text or numbers in it, you can also use the Rev constant "empty", for example:
put empty into field "miles"