Image And trigger

Psk

New Member
I need to create a dinamyc image widget with the mouse-select trigger.
I use this code.

DEFINE INPUT PARAMETER wX AS INTEGER.
DEFINE INPUT PARAMETER wY AS INTEGER.

DEFINE VARIABLE wImagenHnld AS WIDGET-HANDLE.

CREATE IMAGE wImagenHnld
ASSIGN NAME = "IMAGE-" + STRING(wImagenHnld)
FRAME = FRAME {&FRAME-NAME}:HANDLE
TRANSPARENT = TRUE
SELECTABLE = TRUE
X = wX
Y = wY
TOOLTIP = "Click para borrar."
SENSITIVE = TRUE
VISIBLE = TRUE
TRIGGERS:
ON LEFT-MOUSE-CLICK
DO:
MESSAGE "del" VIEW-AS ALERT-BOX.
RETURN.
END.
END TRIGGERS.
wImagenHnld:LOAD-IMAGE("c:\carlos\flecha.gif").
wImagenHnld:MOVE-TO-TOP().


The trigger doesn't works ok. Can anyone help me.
 
Hi,
I've already seen that behaviour. My workaround is:

*** define your widget in the main block with sensitive, select and visible atributes set to false ***

DEFINE VARIABLE wImagenHnld AS WIDGET-HANDLE.
CREATE IMAGE wImagenHnld
ASSIGN NAME =
"IMAGE-" + STRING(wImagenHnld)
FRAME = FRAME {&FRAME-NAME}:HANDLE
TRANSPARENT = TRUE
SELECTABLE = FALSE
X = 1
Y = 1
TOOLTIP = "Click para borrar."
SENSITIVE = FALSE
VISIBLE = FALSE
TRIGGERS:
ON LEFT-MOUSE-CLICK
DO:
MESSAGE "del" VIEW-AS ALERT-BOX.
RETURN.
END.
END TRIGGERS.

*** add this kind of "anywhere" trigger in the main block too ***
ON LEFT-MOUSE-CLICK ANYWHERE DO:
IF SELF:NAME = "IMAGE-" + STRING(wImagenHnld) OR SELF:TYPE <> "button" THEN
APPLY LAST-EVENT:FUNCTION TO SELF.
ELSE
APPLY "CHOOSE" TO SELF.
END.

*** Your procedure becomes this kind of stuff ***
DEFINE INPUT PARAMETER wX AS INTEGER.
DEFINE INPUT PARAMETER wY AS INTEGER.
wImagenHnld:X = wx.
wImagenHnld:Y = wy.
wImagenHnld:VISIBLE = TRUE.
wImagenHnld:SENSITIVE = TRUE.
wImagenHnld:MOVE-TO-TOP().
END PROCEDURE.

Its works...
Dont't use the selectable feature in this case because the first "left click" is "trapped" by the selectable behaviour.
My poor explanation about this is that i think that the image is already realized when you define the trigger and for an unknown reason the ui don't take care of it.

Hope it helps.

Stéphane.
 
Back
Top