Page 1 of 2

PushButton can perform 2 diferent actions?

Posted: Sat Jun 22, 2019 3:56 am
by PedroAlex
Hello.
it is possible for a Pushbutton to perform two different actions?
One for a short click, and one for a long click.
That is, if we click normal on the button it performs a certain action. But pressing the button for more than 3 seconds performs another action.
This is very common in POS applications.
Is this possible?

Many thanks.

Re: PushButton can perform 2 diferent actions?

Posted: Sat Jun 22, 2019 10:44 am
by Auge_Ohr
Button react on BN_CLICKED or BN_DBLCLK so both are "down"

now every XbPart FROM XbpWindow() have o:LbDn and o:LbUp to react.
so you can use a XbpStatic and react like DragDrop when press left Mouse-Button and hold it.

Re: PushButton can perform 2 diferent actions?

Posted: Sat Jun 22, 2019 5:34 pm
by rdonnay
I think I can add this to DCPUSHBUTTOXP.

Re: PushButton can perform 2 diferent actions?

Posted: Mon Jun 24, 2019 1:49 am
by PedroAlex
Hello,
In a TouchScreen scenario, pressing and holding the button makes a lot of sense.
I plan to use it to allow the user to configure their touch keyboard.
So that the user can set the desired actions for that button.
I usually see this functionality in most POS programs that are on the market.
The possibility of a second action on the button increases power in this command.
Maybe a "SetAction"

Many thanks.
I can wait for some news.

Re: PushButton can perform 2 diferent actions?

Posted: Mon Jun 24, 2019 7:18 am
by rdonnay
Maybe a "SetAction"
That's a possibility. Maybe DELAYACTION.

Probably would also require a 2nd parameter the set the delay amount.

@ .. DCPUSHBUTION ACTION <bAction> DELAYACTION <bAction2> CLICKDELAY nSeconds

Of course there would be a Get-Set function to set the default value for CLICKDELAY.

Re: PushButton can perform 2 diferent actions?

Posted: Mon Jun 24, 2019 2:20 pm
by rdonnay
Here is an update for you.

This is the way you use the new parameters:

Code: Select all

#INCLUDE "dcdialog.CH"

FUNCTION Main()

LOCAL GetList[0], oToolBar

DC_XbpPushButtonDelay(1.5)

@ 0,0 DCPUSHBUTTONXP CAPTION 'Test 1' SIZE 20, 1.2  ;
      ACTION {||MsgBox('Action 1')} ;
      DELAYACTION {||MsgBox('Action 2')} CLICKDELAY 2 ;
      COLOR GRA_CLR_WHITE, GRA_CLR_DARKCYAN

@ 2,0 DCPUSHBUTTON CAPTION 'Test 2' SIZE 20, 1.2  ;
      ACTION {||MsgBox('Action 1')} ;
      DELAYACTION {||MsgBox('Action 2')} CLICKDELAY 1.5

@ 4,0 DCTOOLBAR oToolBAR SIZE 30, 1.2

DCADDBUTTONXP CAPTION 'Test 3' SIZE 20, 1.2  ;
      ACTION {||MsgBox('Action 1')} ;
      DELAYACTION {||MsgBox('Action 2')} CLICKDELAY 1 ;
      COLOR GRA_CLR_WHITE, GRA_CLR_DARKPINK ;
      PARENT oToolBar

DCADDBUTTON CAPTION 'Test 4' SIZE 15, 1.2  ;
      ACTION {||MsgBox('Action 1')} ;
      DELAYACTION {||MsgBox('Action 2')}  ;
      PARENT oToolBar

DCREAD GUI FIT

RETURN nil

PROC appsys ; RETURN
Copy _DCXBUTT.PRG to your \exp20\source\dclipx folder.
Copy _DCGETBX.PRG to your \exp20\source\dclipx folder.
Copy DCDIALOG.CH to your \exp20\include folder.

Rebuild DCLIPX.DLL by running BUILD20.BAT or BUILD19_SL1.BAT

Re: PushButton can perform 2 diferent actions?

Posted: Wed Jun 26, 2019 5:54 am
by hz_scotty
Hello!

Build new dclipx.dll only with this 3 files and start my programm - there is a error

Rebuid DLL with the old files - all is perfect - no error

any idea?

Re: PushButton can perform 2 diferent actions?

Posted: Fri Jun 28, 2019 7:16 am
by rdonnay
Did you use the new DCDIALOG.CH file?

Re: PushButton can perform 2 diferent actions?

Posted: Fri Jun 28, 2019 10:43 am
by Sbryan
I'm getting an error too.

I rebuilt dclipx.dll with the new files and ran the included test which worked fine. When I rebuild an existing program with no other changes I get this error when I try to run it.
error.JPG
error.JPG (37.87 KiB) Viewed 14355 times

Re: PushButton can perform 2 diferent actions?

Posted: Fri Jun 28, 2019 2:18 pm
by rdonnay
I think I see the problem but I can't figure out why I'm not getting that error.
I didn't initialize a new variable to a numeric.

Here is an updated _DCXBROW.PRG