Page 2 of 3
Re: Right click in DCBrowse
Posted: Fri Mar 04, 2011 9:45 am
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).
Re: Right click in DCBrowse
Posted: Fri Mar 04, 2011 11:17 pm
by skiman
Hi Tom,
Maybe, but I want it different.
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.
Re: Right click in DCBrowse
Posted: Sat Mar 05, 2011 12:24 am
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?
Re: Right click in DCBrowse
Posted: Sat Mar 05, 2011 8:55 am
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
Re: Right click in DCBrowse
Posted: Mon Mar 07, 2011 12:53 am
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.
Re: Right click in DCBrowse
Posted: Mon Mar 07, 2011 8:26 am
by rdonnay
Can you please give me some source code showing the problem.
I cannot reproduce it.
Re: Right click in DCBrowse
Posted: Mon Mar 07, 2011 12:31 pm
by skiman
Roger,
In attachment a modified autorest.prg.
You will see the different actions.
Re: Right click in DCBrowse
Posted: Tue Mar 08, 2011 11:51 pm
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
Re: Right click in DCBrowse
Posted: Tue Mar 08, 2011 11:59 pm
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.
Re: Right click in DCBrowse
Posted: Wed Mar 09, 2011 8:02 am
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