Page 1 of 2
Selezione con il mouse
Posted: Thu Nov 02, 2023 11:32 am
by Gfb22
Domanda sicuramente ...banale.
In una DataBrowser come quella dell'esempio cosa devo fare per poter scegliere il record evidenziato con il doppio click del mouse in alternativa alla scelta con il Default Button?
Grazie per i suggerimenti...
Re: Selezione con il mouse
Posted: Thu Nov 02, 2023 3:40 pm
by FFF
Your Defaultbutton has the code to return the complete record?
Pseudocode:
GfBBrowser inherit Databrowser
Method MouseButtonDoubleclick(..)
Super: Method MouseButtonDoubleclick(..)
Self:Owner:yourButtonname
...
Re: Selezione con il mouse
Posted: Thu Nov 02, 2023 9:05 pm
by Gfb22
Hi Karl,
this is the code (ButtonOk is the default button) but when you double click nothing happens.
What did I forget?
Thank you!
Gfb
Code: Select all
method MouseButtonDoubleClick(oMouseEvent) class ScegliSchBrowse
local nButtonID as int
nButtonID := IIf(oMouseEvent == NULL_OBJECT, 0, oMouseEvent:ButtonID)
super:MouseButtonDoubleClick(oMouseEvent)
//Put your changes here
self:Owner:ButtonOK() // Return choice code to the Owner
return nil
Re: Selezione con il mouse
Posted: Fri Feb 23, 2024 6:33 pm
by Gfb22
Hi all!
Riprendo X# dopo alcuni mesi in cui ho fatto altro.
In una dataBrowse non riesco a selezionare un record usando DoubleClick.
Di seguito il mio codice, sia con
ButtonDoubleClick() che con
MouseButtonDoubleClick(), come di seguito.
Code: Select all
method ButtonDoubleClick(oControlEvent) class StdDataWindow
local oControl as Control
LOCAL oTB as TextBox
oControl := iif(oControlEvent == null_object, null_object, oControlEvent:Control)
super:ButtonDoubleClick(oControlEvent)
//Put your changes here
self:Owner:ViewRecord()
return nil
method MouseButtonDoubleClick(oMouseEvent) class StdDataWindow
local nButtonID as int
LOCAL oTB as TextBox
nButtonID := iif(oMouseEvent == null_object, 0, oMouseEvent:ButtonID)
super:MouseButtonDoubleClick(oMouseEvent)
//Put your changes here
self:Owner:ViewRecord()
return nil
METHOD ViewRecord() CLASS StandardShellWindow
LOCAL oTB as TextBox
oTB := TextBox{self, "View record", "Record n. " + NTrim(self:oNewChild:Server:RECNO)}
oTB:Type := BUTTONOKAY
oTB:Show()
RETURN nil
Per capire meglio cosa sbaglio allego un piccolo AEF di esempio.
Grazie per ogni suggerimento: certamente c'è qualcosa che manca...
Gfb
Re: Selezione con il mouse
Posted: Sat Feb 24, 2024 8:03 am
by Chris
Hi Gian,
Unfortunately due to the way the VOSDK and the DataBrowser is designed, you need to trap this at the browser level, in a subclass. Create one like this:
Code: Select all
CLASS ParentDataBrowser INHERIT DataBrowser
METHOD CellDoubleClick() CLASS ParentDataBrowser
IF IsMethod(SELF:Owner,#SubFormCellDoubleClick)
Send(SELF:Owner,#SubFormCellDoubleClick)
END IF
RETURN NIL
and then in the Init() of your StdDataWindow add this just after the SUPER:Init() call, in order to tell it to create the databrowser using your new class:
Code: Select all
SUPER:Init(oParentWindow)
SELF:BrowserClass := #ParentDataBrowser
then, you can define a method in the window to do what you want:
Code: Select all
METHOD SubFormCellDoubleClick() CLASS StdDataWindow
SELF:Owner:ViewRecord()
RETURN NIL
Re: Selezione con il mouse
Posted: Sat Feb 24, 2024 5:40 pm
by Gfb22
Hi Chris,
thanks for your time!
In VO it works well; in XIDE it gives me this error:
and this is the line of code that generates the error (line 54):
Code: Select all
SELF:oNewChild:ViewAs(#BrowseView)
and this is the DoOpenFile() method
Code: Select all
METHOD DoOpenFile(cFileName, lReadOnly, cIndex)
LOCAL oTB AS TextBox
IF (Len(cFileName) > 3 ) .AND. (Upper(Right(cFileName, 4)) == ".DBF")
SELF:oNewChild := StdDataWindow{SELF, cFileName, lReadOnly}
SELF:oNewChild:ViewAs(#BrowseView)
// Imposta ReadOnly
SELF:oNewChild:Browser:SetStandardStyle(gbsReadOnly)
SELF:oNewChild:Show(SHOWCENTERED)
ELSE
oTB := TextBox{SELF, "File Open Error", "Cannot open " + cFileName + " - Not a DBF file"}
oTB:Type := BUTTONOKAY
oTB:Show()
ENDIF
RETURN SELF
Thanks for the tips
gfb
Re: Selezione con il mouse
Posted: Sat Feb 24, 2024 8:51 pm
by robert
Gian,
Add a constructor to the class
Code: Select all
CLASS ParentDataBrowser INHERIT DataBrowser
CONSTRUCTOR(oOwner, xID, oPoint, oDimension)
SUPER(oWin, xID, oPoint, oDimension)
RETURN
METHOD CellDoubleClick() CLASS ParentDataBrowser
IF IsMethod(SELF:Owner,#SubFormCellDoubleClick)
Send(SELF:Owner,#SubFormCellDoubleClick)
END IF
RETURN NIL
Robert
Re: Selezione con il mouse
Posted: Sun Feb 25, 2024 8:01 am
by Gfb22
Thanks Robert,
but the error is the same on the line:
Code: Select all
SELF:oNewChild:ViewAs(#BrowseView)
gfb
Re: Selezione con il mouse
Posted: Sun Feb 25, 2024 10:06 am
by robert
If you remove the line
Code: Select all
SELF:BrowserClass := #ParentDataBrowser
then the browser opens?
Robert
Re: Selezione con il mouse
Posted: Sun Feb 25, 2024 1:53 pm
by Gfb22
If I remove the line:
Code: Select all
SELF:BrowserClass := #ParentDataBrowser
there is a new error:
".
.description : No exported method 'SETSTANDARDSTYLE'
Subsystem : BASE
GenCode : EG_NOMETHOD No exported method"
at line:
Code: Select all
SELF:oNewChild:Browser:SetStandardStyle(gbsReadOnly)
.
If I remove this line too, the browser opens but Double Click doesn't work...
gfb