Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Container and mouse events
Message
 
À
17/09/2003 10:06:03
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00829417
Message ID:
00829867
Vues:
23
Wow! Thanks for taking the time to do that. I guess my biggest question is why mouseleave fires unexpectedly in my code. In your example we can get around it by checking the mouse position. In practice, my container has 3 shapes and 6 labels. That would be cumbersome to accomodate all those controls.

>
>oForm=Createobject('TestForm')
>oForm.AddObject('myContainer','Container')
>With oForm.MyContainer
>  .Left = 20
>  .Top = 30
>  .Height = 300
>  .Width = 300
>  .AddObject('oContainer','TestContainer')
>Endwith
>oForm.SetAll('Visible', .T.)
>oForm.Show
>Read Events
>
>Define Class TestContainer As Container
>  Width = 100
>  Height = 100
>  Top  =100
>  Left =100
>  BackColor=Rgb(255,0,0)
>  Add Object oBox As TestBox
>  X1=0
>  X2=0
>  Y1=0
>  Y2=0
>  Procedure Init
>  Local nTreshHold
>  nTreshHold = 2
>  With This
>    .Y1 = Objtoclient(This, 1) + nTreshHold
>    .X1 = Objtoclient(This, 2) + nTreshHold
>    .Y2 = Objtoclient(This, 1) + .Height - nTreshHold
>    .X2 = Objtoclient(This, 2) + .Width  - nTreshHold
>  Endwith
>Endproc
>  Procedure MouseLeave
>  Lparameters nButton, nShift, nXCoord, nYCoord
>  With This
>    If !Between(nXCoord, .X1,.X2) Or ;
>        !Between(nYCoord, .Y1,.Y2)
>      Wait Window This.Name Timeout 1
>    Endif
>  Endwith
>Endproc
>Enddefine
>
>Define Class TestBox As Shape
>  Width=50
>  Height=50
>  Top=25
>  Left=25
>  BackColor=Rgb(0,255,0)
>Enddefine
>
>Define Class TestForm As Form
>  AutoCenter=.T.
>  Width=500
>  Height=500
>  Scalemode=3 && Default
>  Procedure Unload
>  Clear Events
>Endproc
>Enddefine
>
PS: Outer host container is added only to show why objtoclient.
>Cetin
>
>>Unless I did something wrong I'm a bit confused. I understood that the mouseleave would fire when moving from the container to the shape. It tells me that oContainer is active. However when I move back from the shape to the container, oContainer.mouseleave fires again telling me oContainer is active. It doesn't seem like that should happen.
>>
>>
>>oForm=CREATEOBJECT('TestForm')
>>oForm.ADDOBJECT('oContainer','TestContainer')
>>oForm.SHOW
>>READ EVENTS
>>
>>DEFINE CLASS TestContainer AS CONTAINER
>>	ADD OBJECT oBox AS TestBox
>>	WIDTH=100
>>	HEIGHT=100
>>	TOP=100
>>	LEFT=100
>>	BACKCOLOR=RGB(255,0,0)
>>	VISIBLE=.T.
>>	PROCEDURE MOUSELEAVE
>>		LPARAMETERS nButton, nShift, nXCoord, nYCoord
>>		=MESSAGEBOX(THIS.NAME)
>>	ENDPROC
>>ENDDEFINE
>>
>>DEFINE CLASS TestBox AS SHAPE
>>	WIDTH=50
>>	HEIGHT=50
>>	TOP=25
>>	LEFT=25
>>	BACKCOLOR=RGB(0,255,0)
>>ENDDEFINE
>>
>>DEFINE CLASS TestForm AS FORM
>>	AUTOCENTER=.T.
>>	WIDTH=300
>>	HEIGHT=300
>>	PROCEDURE UNLOAD
>>		CLEAR EVENTS
>>	ENDPROC
>>ENDDEFINE
>>
>>
>>
>>>>I have a container class in vfp7. The container contains a variety of controls such as shapes, labels... etc. The container has a mouseenter and mouseleave event routine for displaying/removing a popup editbox. Unfortunately the mouseenter fires when you enter the container then mouseleave fires when you pass over any control in the container. While I can understand that this may be the intended behavior, is there any way to make it so that mouseenter and mouseleave fire when entering and leaving the container only?
>>>
>>>Joe,
>>>A transparent container covering all would do it but might be cumbersome to write 'pass-click' codes.
>>>You might instead check if the object is a member of container (or one of its object members) in MouseLeave.
>>>Cetin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform