Manipulating user input in Touch Panels
etgaspar
Posts: 12
Hi guys, I'm trying to learn the ropes in AMX programming, so I hope you can answer my questions.
I wanted to create a calculator application in the touch panel as a warm up to Netlinx, but i'm having trouble displaying the button presses. What I wanted was for every corresponding button push event, i store that value to an array.
What's next? How do display that result? Is there some sort of "Button1.Text = result" command in Netlinx?
Thanks.
I wanted to create a calculator application in the touch panel as a warm up to Netlinx, but i'm having trouble displaying the button presses. What I wanted was for every corresponding button push event, i store that value to an array.
What's next? How do display that result? Is there some sort of "Button1.Text = result" command in Netlinx?
Thanks.
0
Comments
Button Events
Button events include pushes, releases and holds. These events are associated with a push or release on a particular device-channel.
Example:
BUTTON_EVENT[DEVICE,CHANNEL] or
BUTTON_EVENT[(DEVCHAN[ ])]
{
PUSH:
{
// PUSH event handler
}
RELEASE:
{
// RELEASE event handler
}
HOLD[TIME]: or HOLD[TIME, REPEAT]:
{
// HOLD event handler
}
}
A HOLD event handler specifies the actions that should be performed when a button is pressed and held for a minimum length of time indicated by the TIME parameter (TIME is specified in 0.1 second increments).
The REPEAT keyword is used to specify that the event notification should be repeated in TIME increments as long as the button is held.
The BUTTON object is available to the button event handler as a local variable. The following table lists the information contained in Button Objects.
Property Name
Type
Description
Button.Input
DEVCHAN
Device + Channel
Button.Input.Channel
INTEGER
Channel
Button.Input.Device
DEV
Device
Button.Input.Device.Number
INTEGER
Device number
Button.Input.Device.Port
INTEGER
Device port
Button.Input.Device.System
INTEGER
System number
Button.Holdtime
LONG
Current hold time in .10 second increments.
Note: Button.Holdtime returns are in 1ms increments.
Button.SourceDev
DEV
Source device of button event
Button.SourceDev.Number
INTEGER
Source device number
Button.SourceDev.Port
INTEGER
Source device port
Button.SourceDev.System
INTEGER
Source device system.
If the event handler is specified using an array for DEV, CHANNEL, or a DEVCHAN array, GET_LAST can determine which index in the array caused the event to run.
SEND_COMMAND dvTP, '^TXT-42,0,Hello World!'
the "42" is the address code of a button to update (must be set in TP4). The 0 is for state number, and is usually left at 0. The text to show is everything after the second comma.
I was doing something like this for my calculator app.
DEFINE_VARIABLE
float num = 0
DEFINE_EVENT
button_event [TP,3] // button 1 is pressed
{
PUSH:
{
num = (num * 10) + 1
SEND_COMMAND TP, "'^TXT-1,1,',ftoa(num)"
}
}
button_event [TP,4] // button 2 is pressed
{
PUSH:
{
num = (num * 10) + 2
SEND_COMMAND TP, "'^TXT-1,1,',ftoa(num)"
}
}
.
.
.
If there are other ways of displaying the text, that would be fine, because I may be doing a "Search Movies" query application for a MAX Server in the future, so any suggestions would be appreciated.
What I do is convert them all to Float, calculate, then convert back to ASCII so that I can use it in send_command. My hunch is that the part when I convert the values to Float, the calculation automatically does that. Any other options?
FLOAT
An intrinsic data type representing a 32-bit signed floating point value.
DOUBLE
An intrinsic data type representing a 64-bit (double precision) signed floating point value.
Just a thought