Un TextGadget qui réponde à la souris...
-
- Messages : 64
- Inscription : lun. 07/févr./2005 11:18
Un TextGadget qui réponde à la souris...
Je cherche un gadget qui aurait les caractéristiques d'un textgadget sans bord, mais qui réponde au clic de la souris.
-
- Messages : 64
- Inscription : lun. 07/févr./2005 11:18
Code : Tout sélectionner
If WindowEvent() = #WM_LBUTTONDOWN
If GadgetID(#TextGadget) = WindowFromPoint_(DesktopMouseX(), DesktopMouseY())
; [TON_CODE]
EndIf
EndIf
-
- Messages : 64
- Inscription : lun. 07/févr./2005 11:18
C'est ce que j'utilise, mais malheureusement ça ne marche pas avec les textgadget.......
Dernière modification par barnierchristophe le mer. 09/mai/2007 0:00, modifié 1 fois.
et en trichant ?
Dri
Code : Tout sélectionner
If OpenWindow(0, 0, 0, 322, 35, "TextGadget")
CreateGadgetList(WindowID(0))
StringGadget(5, 8, 10, 306, 20, "ton texte ici", #PB_String_ReadOnly|#PB_String_BorderLess)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
-
- Messages : 64
- Inscription : lun. 07/févr./2005 11:18
Autant pour moi, dans ce cas on peut y aller à la conan :
Code : Tout sélectionner
If OpenWindow(0, 0, 0, 300, 50, "TextGadget")
If CreateGadgetList(WindowID(0))
ContainerGadget(0, 5, 5, 295, 40)
TextGadget(1, 0, 0, GadgetWidth(0), GadgetHeight(0), "Ton texte")
CloseGadgetList()
Repeat
event = WaitWindowEvent()
Select event
Case #WM_LBUTTONDOWN
If GadgetID(0) = WindowFromPoint_(DesktopMouseX(), DesktopMouseY())
Debug "ok"
EndIf
EndSelect
Until event = #PB_Event_CloseWindow
EndIf
EndIf
-
- Messages : 64
- Inscription : lun. 07/févr./2005 11:18
bah y suffit de tricher jusqu'au bout
Dri
Code : Tout sélectionner
#ClickableTextGadget = #ES_MULTILINE | #PB_String_ReadOnly | #PB_String_BorderLess
If OpenWindow(0, 0, 0, 322, 60, "TextGadget")
CreateGadgetList( WindowID(0) )
StringGadget(5, 8, 10, 306, 40, "ton texte" + #CRLF$ + "ici", #ClickableTextGadget)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Ou sans tricher en gardant le textgadget :
Code : Tout sélectionner
Procedure.b CurseurSurGadget(gadget, fenetre)
x = WindowMouseX(fenetre) : y = WindowMouseY(fenetre)
gx = GadgetX(gadget) : gy = GadgetY(gadget)
If x >= gx And x <= gx+GadgetWidth(gadget)
If y >= gy And y <= gy+GadgetHeight(gadget)
ProcedureReturn #True
EndIf
EndIf
ProcedureReturn #False
EndProcedure
If OpenWindow(0, 0, 0, 300, 50, "TextGadget")
If CreateGadgetList(WindowID(0))
TextGadget(1, 5, 5, 300, 50, "Ton texte")
Repeat
event = WaitWindowEvent()
Select event
Case #WM_LBUTTONDOWN
If CurseurSurGadget(1, 0)
Debug "ok"
EndIf
EndSelect
Until event = #PB_Event_CloseWindow
EndIf
EndIf
-
- Messages : 64
- Inscription : lun. 07/févr./2005 11:18
La solution de Dr DRi est pas mal, sauf que les textgadget gèrent seuls le retour chariot. Je garderais donc la solution du textgadget doublé avec un container gadget qui me semble la plus pratique. Merci à tous pour vos propositions. Sinon j'utilise la librairie du Soldat Inconnu pour les boutons sans bord; C'est impeccable