From: Paulo Oliveira on
Hi all,
I have a DataDialog with 3 FabPaintLibControl objects, all the 3
controls have a unique context menu, how do I know which of the three
called the menu?
something like this (but the FabPaintLibControl is not focused):

METHOD InserirImagemCTRL() CLASS dtdManutConfEmp
DO CASE
CASE GetFocusedObject()==SELF:oDCccImgLogoEmp1
SELF:Inseririmagem(1)
CASE GetFocusedObject()==SELF:oDCccImgLogoEmp2
SELF:Inseririmagem(2)
CASE GetFocusedObject()==SELF:oDCccImgLogoEmp3
SELF:Inseririmagem(3)
END CASE

Paulo Oliveira

From: Geoff Schaller on
Paulo,

You have a couple of options here and it depends on how generic you wish
to be.

1. Modify the ContextMenu Class

The contextmenu is launched with ShowAsPopup() and it takes the owner
window as a parameter. VO does nothing with this (a pity) but if you
subclass the menu class, save the owner window in a class ivar and then
provide an Owner access exposing this, you can have what you want:

CLASS MyMenu INHERIT Menu
PROTECT oOwner as OBJECT
ACCESS Owner CLASS MyMenu
RETURN SELF:oOwner
METHOD ShowAsPopup(oOwner, oPoint, kButton, kAlignment, oNotOverlap)
CLASS MyMenu
SELF:oOwner := oOwner
RETURN SUPER:ShowAsPopup(oOwner, oPoint, kButton, kAlignment,
oNotOverlap) CLASS MyMenu


oCurrentMenu:Owner

But I don't know when you will have access to the contextmenu and how. I
can't see the rest of your code but for example, in the PreMenuCommand()
method of the window class you have access to the menu object generating
the event and thus you now have access to the control generating the
menu event. This would be about 15 minutes of work. For example:

METHOD PreMenuCommand(oMenuCommandEvent AS @@MenuCommandEvent) AS LOGIC
PASCAL CLASS MyWindow
LOCAL oMyMenu as OBJECT
LOCAL oControl as OBJECT

oMyMenu := oMenuCommandEvent:Menu
oControl := oMyMenu:Owner

(assumes all menus inherit from MyMenu or else a little error checking
needs to take place here)


2. Provide independent Menus

3 controls = 3 menus. So now you have a duplication (triplication <g>)
of menu classes but you can now customise each event name as a way of
detecting the menu event called. This will only take the time it takes
to copy the menu classes but is tedious and needs to be replicated
everywhere you need this. But it is quick and very specific.

Naturally I prefer the first method but either way, it is quite
achievable.

Geoff




"Paulo Oliveira" <paulo(a)clipinfor.com> wrote in message
news:120556df-a298-4246-af8d-c67fbdee1fda(a)j5g2000yqm.googlegroups.com:

> Hi all,
> I have a DataDialog with 3 FabPaintLibControl objects, all the 3
> controls have a unique context menu, how do I know which of the three
> called the menu?
> something like this (but the FabPaintLibControl is not focused):
>
> METHOD InserirImagemCTRL() CLASS dtdManutConfEmp
> DO CASE
> CASE GetFocusedObject()==SELF:oDCccImgLogoEmp1
> SELF:Inseririmagem(1)
> CASE GetFocusedObject()==SELF:oDCccImgLogoEmp2
> SELF:Inseririmagem(2)
> CASE GetFocusedObject()==SELF:oDCccImgLogoEmp3
> SELF:Inseririmagem(3)
> END CASE
>
> Paulo Oliveira

From: Ian on
On 8 Jan, 19:13, Paulo Oliveira <pa...(a)clipinfor.com> wrote:
> Hi all,
> I have a DataDialog with 3 FabPaintLibControl objects, all the 3
> controls have a unique context menu, how do I know which of the three
> called the menu?
> something like this (but the FabPaintLibControl is not focused):
>
> METHOD InserirImagemCTRL() CLASS dtdManutConfEmp
> DO CASE
>         CASE GetFocusedObject()==SELF:oDCccImgLogoEmp1
>                 SELF:Inseririmagem(1)
>         CASE GetFocusedObject()==SELF:oDCccImgLogoEmp2
>                 SELF:Inseririmagem(2)
>         CASE GetFocusedObject()==SELF:oDCccImgLogoEmp3
>                 SELF:Inseririmagem(3)
> END CASE
>
> Paulo Oliveira

Hi Paulo,

Not certain if this is what you need, but I also have windows with
multiple fabpaintlibcontrols and I use the following to determine
which of the image custom controls called the menu;

METHOD MenuCommand(oMenuCommandEvent) CLASS Tab2_EBAYIMAGES
SUPER:MenuCommand(oMenuCommandEvent)
//Put your changes here

do case
case oMenuCommandEvent:Window:Namesym == #CUSTOMCONTROL1
//your code here
//etc
//etc
case oMenuCommandEvent:Window:Namesym == #CUSTOMCONTROL2
//your code here
//etc
//etc
endcase

Hope this helps.

Regards,
Ian
 | 
Pages: 1
Prev: Weird bbrowser problem
Next: Fill bBrowser window