PDA

View Full Version : Buttons: Do action(s) while long pressing



T3STY
06-01-2009, 10:00 AM
Hi all!
As I wrote in the title of this thread, I need help with buttons.
By default, the actions written on the "OnClick" event are done just when user leaves the left click (or right click). For me, it could be usefully doing reapeatly the actions by long pressing the button.

Is there anything can help me doing this?
Tankyou,

p.s. Sorry for my bad english. If anyone can't understand what I wrote just tell me.

Bye!

longedge
06-01-2009, 11:06 AM
I can't think how to do this purely with AMS but I'm sure you could get pretty close, I'd just use a flash button as per this example.

mwreyf1
06-01-2009, 11:12 AM
I think he was talking about something more like this.

I may be wrong.

longedge
06-01-2009, 11:22 AM
I think he was talking about something more like this.

I may be wrong.

:) I was going on -


doing reapeatly the actions by long pressing the button.

mwreyf1
06-01-2009, 11:26 AM
Oh yes, I see.

My bad...

Should have read slower. :rolleyes

T3STY
06-01-2009, 03:05 PM
This is what I need, just, I can't (I don't know how to) modify the code to respond when the left mouse button is down. I've tried but I really can't.
Can you do it for me, please?

Tankyou
Bye!

mwreyf1
06-01-2009, 04:06 PM
Which one do you need modified?

longedge's solution or mine?

Don't think longedge's solution will work with mouse button down.

longedge
06-01-2009, 04:36 PM
Which one do you need modified?

longedge's solution or mine?

Don't think longedge's solution will work with mouse button down.

I was wondering as well but since the example I posted already does what I think is being asked for I don't know what I can add. The button detects as long as the mouse button is kept pressed and then detects when it is released. I just used it to change a label but the code could be anything at all.

As I've said in the past, flash buttons suit me because they allow for more states than standard AMS buttons - roll over, roll out, press, release, release outside, drag over and drag out (although I only ever use the first four).

reteset
06-02-2009, 01:06 AM
some times searching gives you good results ;)

also this is implemented in various examples in the forum

http://www.indigorose.com/forums/showthread.php?t=7670&highlight=hit+test

T3STY
06-03-2009, 03:30 AM
Tankyou for help, isn't what I need at all, but I'll try to build the code my self.

Bye!

longedge
06-03-2009, 03:36 AM
Tankyou for help, isn't what I need at all, but I'll try to build the code my self.

Bye!

OK but just satisfy my curiosity please. When you said "This is what I need, just, I can't (I don't know how to) modify the code to respond when the left mouse button is down. I've tried but I really can't.
Can you do it for me, please?" - who was it addressed to?

MicroByte
06-03-2009, 05:07 AM
Tankyou for help, isn't what I need at all, but I'll try to build the code my self.

man are you trippin?, thats exactly what you need, simply test for a mouse down inside the hittest area and use a timer to repeat the actions


heres a simplified version useiing reteset's timer object plugin (to save the page timer)

Page OnShow

nCounter=0

Page OnMouseButton

if IsInRectEX1("Button1") then
if e_Type == LEFT_BUTTON_DOWN then
TimerID = Timer.StartTimer("Plugin1", 100, 100);
elseif e_Type == LEFT_BUTTON_UP then
Timer.StopTimer("Plugin1", TimerID);
end
end

Timer Object (OnTimer)

if e_TimerId == 100 then
Label.SetText("Label1", "Counter: ("..nCounter..")");
nCounter=nCounter+1
end

and place this function in the global area

function IsInRectEX1(strObject)
mObjType = Page.GetObjectType(strObject)
if mObjType == OBJECT_BUTTON then
m_tblPos = Button.GetPos(strObject)
m_tblSize = Button.GetSize(strObject)
elseif mObjType == OBJECT_FLASH then
m_tblPos = Flash.GetPos(strObject)
m_tblSize = Flash.GetSize(strObject)
elseif mObjType == OBJECT_HOTSPOT then
m_tblPos = Hotspot.GetPos(strObject)
m_tblSize = Hotspot.GetSize(strObject)
elseif mObjType == OBJECT_IMAGE then
m_tblPos = Image.GetPos(strObject)
m_tblSize = Image.GetSize(strObject)
elseif mObjType == OBJECT_INPUT then
m_tblPos = Input.GetPos(strObject)
m_tblSize = Input.GetSize(strObject)
elseif mObjType == OBJECT_LABEL then
m_tblPos = Label.GetPos(strObject)
m_tblSize = Label.GetSize(strObject)
elseif mObjType == OBJECT_LISTBOX then
m_tblPos = ListBox.GetPos(strObject)
m_tblSize = ListBox.GetSize(strObject)
elseif mObjType == OBJECT_PARAGRAPH then
m_tblPos = Paragraph.GetPos(strObject)
m_tblSize = Paragraph.GetSize(strObject)
elseif mObjType == OBJECT_PLUGIN then
m_tblPos = Plugin.GetPos(strObject)
m_tblSize = Plugin.GetSize(strObject)
elseif mObjType == OBJECT_VIDEO then
m_tblPos = Video.GetPos(strObject)
m_tblSize = Video.GetSize(strObject)
elseif mObjType == OBJECT_WEB then
m_tblPos = Web.GetPos(strObject)
m_tblSize = Web.GetSize(strObject)
elseif mObjType == OBJECT_RADIOBUTTON then
m_tblPos = RadioButton.GetPos(strObject)
m_tblSize = RadioButton.GetSize(strObject)
elseif mObjType == OBJECT_RICHTEXT then
m_tblPos = RichText.GetPos(strObject)
m_tblSize = RichText.GetSize(strObject)
elseif mObjType == OBJECT_CHECKBOX then
m_tblPos = CheckBox.GetPos(strObject)
m_tblSize = CheckBox.GetSize(strObject)
elseif mObjType == OBJECT_SLIDESHOW then
m_tblPos = SlideShow.GetPos(strObject)
m_tblSize = SlideShow.GetSize(strObject)
elseif mObjType == OBJECT_GRID then
m_tblPos = Grid.GetPos(strObject)
m_tblSize = Grid.GetSize(strObject)
end
local tMouse=System.GetMousePosition(true);
local m_nX=tMouse.X
local m_nY=tMouse.Y
local bReturn = false;
if (m_nX >= m_tblPos.X) and (m_nX <= m_tblPos.X + m_tblSize.Width) then
if (m_nY >= m_tblPos.Y) and (m_nY <= m_tblPos.Y + m_tblSize.Height) then
bReturn = true;
end
end
return bReturn;
end

or view the example

T3STY
06-03-2009, 05:29 AM
OK MicroByte, that's what I was searching for.
I hope you're not nervous beacuse, by reading your post, seems you are.

However, thanks for help. Now I'm going to continue building my application.
Bye!