Right click in DCBrowse

This forum is for eXpress++ general support.
Message
Author
User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Right click in DCBrowse

#11 Post by Tom »

Hi, Chris.

RBDOWN must be the event firing first, since this is the "real" event (right button of the mouse down), while "RBSELECT" follows this: The right mouse button was clicked into a cellgroup, the cell can be selected, so it creates this event afterwards. The first thing is the "what" (mouse event), the second is the "where" (cellgroup was clicked).
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Right click in DCBrowse

#12 Post by skiman »

Hi Tom,

Maybe, but I want it different. :mrgreen:

This is my situation. I have a browse of products in an invoice. i want to insert a product between two lines. Now I have to select the line where I want to insert, and the I can use the RBDOWN to call my block and insert the product.

I want to insert immediately with one click. My problem is now that with the RBDOWN the record where I clicked isn't selected.
Best regards,

Chris.
www.aboservice.be

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Right click in DCBrowse

#13 Post by skiman »

Hi,

I tested with my own handler. This is the order everything is processed.

- Right Down in the handler.
- RBDOWN code block.
- Right UP in the handler.
- RBSELECT

I found a solution to solve it, so there is no need to modify eXPress++ for me. However, I'm wondering if the above order is logical?
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Right click in DCBrowse

#14 Post by rdonnay »

Chris -

That seems wrong to me, because I use RBSELECT and RBDOWN in lots of applications to pop up a menu in the browse. Bobby Drakos' Taxi software also uses this extensively through the app. I just ran his app to be sure about this and I can see that the record is selected when the menu pops up.

Try putting this in your RBDOWN codeblock:

DCBROWSE .. RBSELECT RBDOWN {||DC_CompleteEvents(), DoSomething()}

Roger
The eXpress train is coming - and it has more cars.

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Right click in DCBrowse

#15 Post by skiman »

Hi Roger,

The menu popup appears at the right position. RBDOWN is passing this position. However the line is not selected at the moment the menu pops up.
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Right click in DCBrowse

#16 Post by rdonnay »

Can you please give me some source code showing the problem.

I cannot reproduce it.
The eXpress train is coming - and it has more cars.

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Right click in DCBrowse

#17 Post by skiman »

Roger,

In attachment a modified autorest.prg.

You will see the different actions.
Attachments
autorest.zip
(1.32 KiB) Downloaded 717 times
Best regards,

Chris.
www.aboservice.be

fransm
Posts: 11
Joined: Fri Feb 05, 2010 10:37 am

Re: Right click in DCBrowse

#18 Post by fransm »

Hi Chris

This is what I use. You will see that I put it in the EVAL clause - I don't use the RBDOWN clause. This code will set focus to the row that you right click on and show the context menu. I am sure that there is someone else that would be able to give a more elegant resolution, but this works for me.

EVAL {|o| o:itemMarked := {|| ;
IIF(lClear ,Eval(bResetSch) ,Nil) ,;
IIF(lClear, DC_GetRefresh(GetList,Nil,DCGETREFRESH_ID_INCLUDE ,;
{'1'}) ,Nil) ,;
IIF(lSearched ,Eval(bSetScope) ,Nil) ,;
lClear := .f. ,lSearched := .f. ,SetAppFocus(oSch) } ,;
o:ItemRbDown := { |mp1,mp2,oXbp| oxbp:dehilite() ,;
(oxbp:datasource)->(Dbskip(mp2[1]-oxbp:rowpos)) ,;
oxbp:rowpos:=mp2[1] ,;
oxbp:refreshall() ,;
eval(bSetscope) ,;
oMenuBrow:PopUp (oXbp,mp1, 1 ,;
XBPMENU_PU_DEFAULT ) } }


regards

frans

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Right click in DCBrowse

#19 Post by skiman »

Hi Frans,

I found a solution for it, but I don't think it is correct behaviour.

I did it as follows:

Code: Select all

RBDOWN {|| lRight := .T. }
ITEMMARKED {|| iif(lRight, startfunction(),),lRight:= .F., .... }
This way the itemmarked is excuting the function I want with the Rclick. At the moment the itemmarked is excuted, the line is already selected.

One problem to solve with the above method: Right clicking on a line which is already selected. I did this in the handler to check for the RBdown event.
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Right click in DCBrowse

#20 Post by rdonnay »

This code works correctly.

The DC_CompleteEvents() insures that the rbdown event moves the browse pointer before the menu is dropped.

Code: Select all

#INCLUDE "dcdialog.CH"
#include "appevent.ch"

FUNCTION Main()

LOCAL GetList[0], GetOptions, aDir, aHeadings, i, oBrowse , lRight := .F.

aDir := Directory()

aHeadings := { 'File;Name', ;
               'File;Size', ;
               'Date;Last;Write', ;
               'Time;Last;Write', ;
               'File;Attr', ;
               'Size;Extend;Attr', ;
               'Create;Date', ;
               'Create;Time', ;
               'Date;Last;Access', ;
               'Time;Last;Access' }

@ 0,0 DCSAY 'Click Right Button in a Column for menu' ;
      SAYSIZE 50 COLOR GRA_CLR_BLUE

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

FOR i := 1 TO Len(aHeadings)
  DCBROWSECOL ELEMENT i HEADER aHeadings[i] ;
     WIDTH 60 PIXEL PARENT oBrowse
NEXT

DCGETOPTIONS ;
   NOMINBUTTON ;
   NOMAXBUTTON ;
   AUTORESIZE ;
   BUTTONALIGN DCGUI_BUTTONALIGN_CENTER

DCREAD GUI ;
   FIT ;
   BUTTONS DCGUI_BUTTON_OK ;
   OPTIONS GetOptions ;
   TITLE 'Directory Browse' ;
   MODAL ;
   SETAPPWINDOW 

RETURN nil

* -------------

STATIC FUNCTION BrowseMenu( oBrowse )

STATIC soMenu, soBrowse

LOCAL GetList[0], i

IF Valtype(soMenu) # 'O' .OR. soMenu:status()<=0 .OR. soBrowse # oBrowse

  IF Valtype(soMenu) = 'O'
    soMenu := nil
  ENDIF

  soBrowse := oBrowse

  DCSUBMENU soMenu

    DCMENUITEM 'Move Column &Left' PARENT soMenu ACTION {||soBrowse:moveColumn(-1)}
    DCMENUITEM 'Move Column &Right' PARENT soMenu ACTION {||soBrowse:moveColumn(1)}
    DCMENUITEM SEPARATOR PARENT soMenu
    DCMENUITEM 'Restore Defaults' PARENT soMenu ACTION {||soBrowse:restoreDefaults()}

  DCREAD GUI ;
    PARENT oBrowse ;
    EXIT

ENDIF

RETURN soMenu

* --------------

STATIC FUNCTION BrowseMenuBlock( oBrowse )

RETURN {|x,y,z,o|DC_CompleteEvents(), ;
                 (wtf oBrowse:datasource[oBrowse:arrayElement,1]), ;
                  o := BrowseMenu( oBrowse ), ;
                  o:popup( nil, x, 1 , ;
                  XBPMENU_PU_DEFAULT + XBPMENU_PU_MOUSE_RBDOWN ) }
* -------------

PROC appsys ; RETURN
The eXpress train is coming - and it has more cars.

Post Reply