Page 1 of 3

Right click in DCBrowse

Posted: Thu Feb 24, 2011 9:53 am
by skiman
Hi,

I have a handler to process a right click in a browse. This is working without a problem.

However I would like to select the line in the browse and process with one click. At this time I have to select the line in the browse with the left button, and then I can click the right button.

The action of my right click is always on the selected line. The user has to click twice, left to select, right to fire the action. I would like to do this with one right click.

With RBSELECT my RIGHT click is fired, and after my action, the line is selected. This is logical, because my handler is evaluated before the standard handler.

Re: Right click in DCBrowse

Posted: Thu Feb 24, 2011 12:31 pm
by rdonnay
I use the combination of RBSELECT and RBDOWN in lots of applications with no problem.

Look at the sample in \exp19\samples\browse\autorest.prg.

Re: Right click in DCBrowse

Posted: Wed Mar 02, 2011 1:24 pm
by skiman
Hi Roger,

It isn't working as expected. I tried the RBDOWN as follows in the autorest.prg.

Code: Select all

@ 1,0 DCBROWSE oBrowse DATA aDir PRESENTATION DC_BrowPres() ;
      SIZE 400,200 PIXEL FIT ;
      ID 'DIRECTORY_BROWSE' ;
      HEADLINES 3 ;
      RBSELECT ;
      RBDOWN msgbox("test")    // BrowseMenuBlock(@oBrowse)
The msgbox is shown at startup, but isn't working when right-clicking?

I didn't find the RBDOWN in the documentation.

Re: Right click in DCBrowse

Posted: Wed Mar 02, 2011 1:31 pm
by skiman
Roger,

I did another test with autorest.prg. I modified the function BrowseMenuBlock. I just added a WTF.

Code: Select all

STATIC FUNCTION BrowseMenuBlock( oBrowse )

wtf "test"

RETURN {|x,y,z,o|o := BrowseMenu( oBrowse ), ;
                                o:popup( nil, x, 1 , ;
                                XBPMENU_PU_DEFAULT + XBPMENU_PU_MOUSE_RBDOWN ) }
The wtf is executed at startup, and not at a right-click.

Re: Right click in DCBrowse

Posted: Wed Mar 02, 2011 1:33 pm
by rdonnay
Chris -

You need to put it in a codeblock.

RBDOWN {||Msgbox('test')}

Re: Right click in DCBrowse

Posted: Wed Mar 02, 2011 1:38 pm
by skiman
Roger,

I will try it, but why is autorest.prg working?

Code: Select all

@ 1,0 DCBROWSE oBrowse DATA aDir PRESENTATION DC_BrowPres() ;
      SIZE 400,200 PIXEL FIT ;
      ID 'DIRECTORY_BROWSE' ;
      HEADLINES 3 ;
      RBSELECT ;
      RBDOWN BrowseMenuBlock(@oBrowse)
As you can see, there is no codeblock.

Addition:
Now I see it. The function BrowseMenuBlock(@oBrowse) is executed when the browse is created. This function returns the required codeblock. This codeblock is executed each time the RBDOWN is fired.

Re: Right click in DCBrowse

Posted: Wed Mar 02, 2011 1:42 pm
by skiman
Yes, that's it. :D

With a codeblock it's working.

Re: Right click in DCBrowse

Posted: Wed Mar 02, 2011 2:06 pm
by skiman
Roger,

It seems as the RBDOWN is executed before the RBSELECT. I'm browsing a database and the RBDOWn codeblock returns the value of the previous selected record.

Could you clarify the RBDOWN {| a,b,c,d | .... } ?

What is passed to the codeblock?

Re: Right click in DCBrowse

Posted: Wed Mar 02, 2011 2:18 pm
by Tom
Hi, Chris.
Could you clarify the RBDOWN {| a,b,c,d | .... }
You can do things like this by yourself:

Code: Select all

RBDOWN {| a,b,c,d | DC_DebugQout(a),DC_DebugQout(b),DC_DebugQout(c),DC_DebugQout(d) }
And you will find out:

a is the absolute position clicked.
b is nil.
c is a reference to the XbpCellGroup-Object (DataArea).
d is nil.

Re: Right click in DCBrowse

Posted: Fri Mar 04, 2011 9:39 am
by skiman
Hi Roger,

With the following changes in autorest you can see that the RBDOWN block is executed before the RBSELECT.

Code: Select all

...
@ 1,0 DCBROWSE oBrowse DATA aDir PRESENTATION DC_BrowPres() ;
      SIZE 400,200 PIXEL FIT ;
      ID 'DIRECTORY_BROWSE' ;
      HEADLINES 3 ;
      RBSELECT ;
      RBDOWN {|| BrowseMenuBlock(@oBrowse) }
...

STATIC FUNCTION BrowseMenuBlock( oBrowse )
wtf 'rbdown'
sleep(500)

RETURN .T.
The original autorest seemed to work, because the menu is positioned at the position of the cursor. However, the row in the browse isn't selected at the moment the menu appear.

With the above modification you can see that the codeblock is executed, and after this the RBSELECT is activated.

Maybe I can check this in my own handler by looking for the rbUP? Have to test this.