DCBROWSE RBSELECT
DCBROWSE RBSELECT
I do use DCBROWSE with the RBSELECT clause very often. Unfortunately, RBSELECT (itemRbSelect) fires too late.
I have popup menus connected to the dataareas, or custom handlers which provide a special kind of drag&drop with RbDown. But with RBSELECT, the pointer is not at the right position in this moment, so the WHEN clauses of the popup menus don't react correctly, or the wrong portion of cells is taken with d&d. Any ideas how to set the browse position with RbDown before the event is recognized in the handler?
I have popup menus connected to the dataareas, or custom handlers which provide a special kind of drag&drop with RbDown. But with RBSELECT, the pointer is not at the right position in this moment, so the WHEN clauses of the popup menus don't react correctly, or the wrong portion of cells is taken with d&d. Any ideas how to set the browse position with RbDown before the event is recognized in the handler?
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: DCBROWSE RBSELECT
Tom -
Is there a short sample you can give me that I can work with?
Roger
Is there a short sample you can give me that I can work with?
Roger
The eXpress train is coming - and it has more cars.
Re: DCBROWSE RBSELECT
Hi, Roger.
Compile and run this. If you hit the right mouse button in a new (!) line, the debug code inside the handler will show the data from the line where the pointer was before:
To be honest, I don't believe there's a solution for this, since oBrowse:itemRbDown, which is used by your RBSELECT clause, fires to late. But maybe you have an idea for a workaround.
Compile and run this. If you hit the right mouse button in a new (!) line, the debug code inside the handler will show the data from the line where the pointer was before:
Code: Select all
#include "dcdialog.ch"
#include "appevent.ch"
#pragma library ("dclipx.lib")
FUNCTION Main()
LOCAL GetList := {}, GetOptions := {}, oBrowse, aDirectory
aDirectory := Directory()
@ 0,0 DCBROWSE oBrowse DATA aDirectory SIZE 100,20 RBSELECT FIT
DCBROWSECOL ELEMENT 1 Header 'Name' PARENT oBrowse WIDTH 20
DCBROWSECOL ELEMENT 2 Header 'Size' PARENT oBrowse WIDTH 10
DCBROWSECOL ELEMENT 3 Header 'Date' PARENT oBrowse WIDTH 10
DCBROWSECOL ELEMENT 4 Header 'Time' PARENT oBrowse WIDTH 10
DCBROWSECOL ELEMENT 5 Header 'Attrs.' PARENT oBrowse WIDTH 10
DCREAD GUI FIT TITLE 'Test' ;
HANDLER myHandler REFERENCE @oBrowse
RETURN nil
STATIC FUNCTION myHandler(nEvent, mp1, mp2, oXbp, oDlg, GetList, oBrowse)
IF Valtype(oXbp) = 'O' .and. nEvent == xbeM_RbDown
DCQDEBUGQUIET oBrowse:ArrayElement, oBrowse:DataSource[DC_BrowseRow(oBrowse),1]
ENDIF
RETURN DCGUI_NONE
PROC AppSys() ; RETURN
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: DCBROWSE RBSELECT
I had a similar problem with one of Bobby Drakos applications and solved the problem using DC_SaveEvents() and DC_RestoreEvents().To be honest, I don't believe there's a solution for this, since oBrowse:itemRbDown, which is used by your RBSELECT clause, fires to late. But maybe you have an idea for a workaround.
I don't know if it will work in this situation but I'll give it a try.
The eXpress train is coming - and it has more cars.
Re: DCBROWSE RBSELECT
I found a workaround that works for me.
Code: Select all
STATIC FUNCTION myHandler(nEvent, mp1, mp2, oXbp, oDlg, GetList, oBrowse)
LOCAL nCell
IF Valtype(oXbp) = 'O' .and. oXbp:isDerivedFrom('XbpCellGroup') .AND. nEvent == xbeM_RbDown
nCell := oXbp:cellFromPos(mp1)
oBrowse:itemRbDown( mp1, { oXbp:parent, nCell } )
oBrowse:forceStable()
wtf oBrowse:arrayElement
RETURN DCGUI_IGNORE
ENDIF
RETURN DCGUI_NONE
The eXpress train is coming - and it has more cars.
Re: DCBROWSE RBSELECT
Thanks, Roger! Works excellent!
If someone uses this: Keep the RBSELECT clause in your DCBROWSE code. This is the adjusted sample:
If someone uses this: Keep the RBSELECT clause in your DCBROWSE code. This is the adjusted sample:
Code: Select all
#include "dcdialog.ch"
#include "appevent.ch"
#pragma library ("dclipx.lib")
FUNCTION Main()
LOCAL GetList := {}, GetOptions := {}, oBrowse, aDirectory
aDirectory := Directory()
@ 0,0 DCBROWSE oBrowse DATA aDirectory SIZE 100,20 RBSELECT FIT
DCBROWSECOL ELEMENT 1 Header 'Name' PARENT oBrowse WIDTH 20
DCBROWSECOL ELEMENT 2 Header 'Size' PARENT oBrowse WIDTH 10
DCBROWSECOL ELEMENT 3 Header 'Date' PARENT oBrowse WIDTH 10
DCBROWSECOL ELEMENT 4 Header 'Time' PARENT oBrowse WIDTH 10
DCBROWSECOL ELEMENT 5 Header 'Attrs.' PARENT oBrowse WIDTH 10
DCREAD GUI FIT TITLE 'Test' ;
HANDLER myHandler REFERENCE @oBrowse
RETURN nil
STATIC FUNCTION myHandler(nEvent, mp1, mp2, oXbp, oDlg, GetList, oBrowse)
LOCAL nCell
IF Valtype(oXbp) = 'O' .and. oXbp:isDerivedFrom('XbpCellGroup') .AND. nEvent == xbeM_RbDown
nCell := oXbp:cellFromPos(mp1)
oBrowse:itemRbDown( mp1, { oXbp:parent, nCell } )
oBrowse:forceStable()
ENDIF
IF Valtype(oXbp) = 'O' .and. nEvent == xbeM_RbDown
DCQDEBUGQUIET oBrowse:ArrayElement, oBrowse:DataSource[DC_BrowseRow(oBrowse),1]
ENDIF
RETURN DCGUI_NONE
PROC AppSys() ; RETURN
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: DCBROWSE RBSELECT
@Tom
Your new code works but skip back one line when RB-Down in Browse!
is this ok?
Rogers Version works all correct - i think
Your new code works but skip back one line when RB-Down in Browse!
is this ok?
Rogers Version works all correct - i think
best regards
Hans
Hans
Re: DCBROWSE RBSELECT
Looks as this is the difference between the two:
RETURN DCGUI_IGNORE in Rogers code.
RETURN DCGUI_IGNORE in Rogers code.
Re: DCBROWSE RBSELECT
Hi, Chris.
This is because the xbeM_RbDown is recognized two times in the handler - first to set the browse pointer, second to do something with rbdown. This is why I'm doing all this.
By the way: Using the itemRbDown-method manipulates the mp1 array (mouse position). Saving it before and restoring it after that solves this issue. If there would be a menu popup on rbdown after this code, the menu would appear at the wrong position.
This is because the xbeM_RbDown is recognized two times in the handler - first to set the browse pointer, second to do something with rbdown. This is why I'm doing all this.
By the way: Using the itemRbDown-method manipulates the mp1 array (mouse position). Saving it before and restoring it after that solves this issue. If there would be a menu popup on rbdown after this code, the menu would appear at the wrong position.
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: DCBROWSE RBSELECT
Hi, Hans.
You're right. Seems that RBSELECT causes itemRbDown to fire again with the wrong position. If RBSELECT is not used, itemRbDown will not fire anyway, since it's only set (it's a slot) if RBSELECT is used.Your new code works but skip back one line when RB-Down in Browse!
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."