Salut a tous
pour ceux que ça intéressent, une petite démo
Appuyez sur la touche entrée, pour faire défiler, ou cliquez sur le texte pour sélectionner.
Code : Tout sélectionner
;option des gadgets
Enumeration
#Window_0 = 1
#string_1 = 2
#string_2 = 3
#string_3 = 4
EndEnumeration
Procedure colorstring(gadget)
x = GadgetX(gadget)
y = GadgetY(gadget)
Largeur = GadgetWidth(gadget)
Hauteur = GadgetHeight(gadget)
If EventType() = #PB_EventType_Focus
StringGadget(3000, x, y, Largeur, Hauteur, GetGadgetText(gadget),0);3000 est un numéro bidon pour simulé la création d'un nouveau gadget
SetGadgetColor(3000,#PB_Gadget_BackColor,$39E3C6)
EndIf
If EventType() = #PB_EventType_LostFocus
StringGadget(3000, x, y, Largeur, Hauteur, GetGadgetText(gadget),#PB_String_BorderLess)
SetGadgetColor(3000,#PB_Gadget_BackColor,$B7D9D9)
EndIf
EndProcedure
OpenWindow (#Window_0, 388, 23, 414, 182, "Test" , #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_WindowCentered )
AddKeyboardShortcut(#Window_0, #PB_Shortcut_Return, 0) ; menu bidon pour traitement du clavier dans les string gadgjet
StringGadget(#string_1, 20, 20, 100,20,"AAAAAAAA",#PB_String_BorderLess)
SetActiveGadget(#string_1)
StringGadget(#string_2, 20, 60, 100,20,"BBBBBBBBB",#PB_String_BorderLess)
StringGadget(#string_3, 20, 100, 100,20,"CCCCCCCCC",#PB_String_BorderLess)
For y = 2 To 4
SetGadgetColor(y,#PB_Gadget_BackColor,$E0E0E0)
SetGadgetColor(y,#PB_Gadget_FrontColor,$EA4F07)
Next
Repeat
Event = WaitWindowEvent()
Select EventMenu()
Case 0
If GetActiveGadget() = #string_1
SetActiveGadget(#string_2)
Else
If GetActiveGadget() = #string_2
SetActiveGadget(#string_3)
Else
If GetActiveGadget() = #string_3
SetActiveGadget(#string_1)
EndIf
EndIf
EndIf
EndSelect
If Event = #PB_Event_Gadget
Select EventGadget()
Case #string_1
colorstring(#string_1)
Case #string_2
colorstring(#string_2)
Case #string_3
colorstring(#string_3)
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
Pour la sélection ok; mais si ons fait une modif du texte la couleur de fond pose un problème??