Page 1 sur 1

ScreenGadget : Souci identifiant

Publié : mer. 08/oct./2025 14:04
par falsam
PureBasic 6.30 Beta 3

Petit code 3D qui affiche un cube ainsi qu'un ButtonScreenGadget() (Nouveauté PB 6.30)

Ce bouton est testé dans une boucle évènementielle de cette manière.

Code : Tout sélectionner

  ; Traiter les evenements ScreenWindow
  If ScreenWindowEvent() = #PB_Event_Gadget
    Select EventScreenGadget()
      Case #clickMe
        Debug "Bouton clickMe sélectionné"
      EndSelect
  EndIf
■ Quand je clique n'importe ou sur le rendu final (Sauf sur le bouton ClickMe) je n'ai aucun message m'avertissant que j'ai cliqué sur le bouton ClickMe. C'est normal 👍

■ Je clique sur le bouton ClickMe et j'ai un message message m'avertissant que j'ai cliqué sur le bouton ClickMe. C'est normal 👍

Si je clique par la suite n'importe ou sur l'écran j'ai malheureusement le même message 🤔

➡️ Bug ou bien je n'ai pas fait ce qu'il fallait dans ce code de test ci dessous ?

Code : Tout sélectionner

EnableExplicit

Enumeration
  #clickMe
EndEnumeration

; DPI Resolution
Global drx.f, dry.f

; Evenement window
Global Event, ScreenGadget

; Sprite Help
Global Bottom, FontInfo = LoadFont(#PB_Any, "Arial", 12)

Global FPS

; Initialisation de l'environnement 3D
If InitEngine3D(#PB_Engine3D_DebugLog) = 0 Or InitSprite() = 0  Or InitKeyboard() = 0 Or InitMouse() = 0
  MessageRequester("Information", "Souci d'initialisation environnement 3D")
EndIf

drx = DesktopResolutionX()
dry = DesktopResolutionY()

ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "", #PB_Window_Maximize | #PB_Window_BorderLess)
OpenWindowedScreen(WindowID(0),0, 0, WindowWidth(0)*drx , WindowHeight(0)*dry, 0, 0, 0, #PB_Screen_WaitSynchronization) 

InitScreenGadgets()

ButtonScreenGadget(#clickMe, 10, 10, 100, 50, "Click Me")

; Clavier international
KeyboardMode(#PB_Keyboard_International | #PB_Keyboard_AllowSystemKeys)

; Camera
CreateCamera(0, 0, 0, 100, 100)
CameraBackColor(0, RGB(0, 139, 139))
MoveCamera(0, 3, 6, 10, #PB_Absolute)
CameraLookAt(0, 0, 0, 0)

; Light
AmbientColor(RGB(255, 165, 0))
CreateLight(0, $ffffff, -5, 10, 10)

; Un cube
CreateCube(0, 1)
CreateEntity(0, MeshID(0), #PB_Material_None)

;- Création du sprite Help
Bottom = CreateSprite(#PB_Any, ScreenWidth(), 150, #PB_Sprite_AlphaBlending)
If StartDrawing(SpriteOutput(Bottom))
  DrawingFont(FontID(FontInfo))
  DrawingMode(#PB_2DDrawing_AlphaChannel)
  Box(0, 0, ScreenWidth(), SpriteHeight(Bottom), RGBA(0, 0, 0, 140))
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(10, 10, ". : : Help : : .")
  DrawText(10, 40, "Touche Escape pour quitter.")
  StopDrawing()
EndIf 

; Boucle evenementielle
Repeat
  ; Traiter les évenement windows de la file d'attente
  While WindowEvent():Wend
  
  ; Traiter les evenements ScreenWindow
  If ScreenWindowEvent() = #PB_Event_Gadget
    Select EventScreenGadget()
      Case #clickMe
        Debug "Bouton clickMe sélectionné"
      EndSelect
  EndIf 
  
  ; Evenements 2D/3D
  ExamineKeyboard()
  ExamineMouse()  
  
  ; Rendu 3D
  RenderWorld()
  
  ; Rendu 2D
  DisplayTransparentSprite(Bottom, 0, ScreenHeight()-SpriteHeight(Bottom))
  
  ; Rendu screengadgets
  RenderScreenGadgets()
  
  ; Basculement ancienne image / nouvelle image du rendu final
  FlipBuffers() 
Until KeyboardPushed(#PB_Key_Escape)
Je pense que Guillot (Créateur de la bibliothèque ScreenGadget) sera à même de me répondre.

D'avance merci.

Re: ScreenGadget : Souci identifiant

Publié : mer. 08/oct./2025 14:46
par falsam
J'ai ajouté une fenêtre au code précédent avec la fonctionnalité OpenScreenWindow()

Code : Tout sélectionner

OpenScreenWindow(#win3d, 10 ,50 ,300, 530,"OpenScreenWindow")
■ Vous pouvez déplacer cette fenêtre. Au passage bravo pour cette nouvelle bibliothèque.

■ Essayer maintenant de déplacer cette fenêtre en maintenant le clic gauche de la souris n'importe ou sur le screen (sauf sur la fenêtre). L'OpenScreenWindow se déplacera aussi alors que le pointeur de la souris ne se trouve pas dessus.

Voici le code de test.

Code : Tout sélectionner

EnableExplicit

Enumeration
  #clickMe
  
  #win3d
EndEnumeration

; DPI Resolution
Global drx.f, dry.f

; Evenement window
Global Event, ScreenGadget

; Sprite Help
Global Bottom, FontInfo = LoadFont(#PB_Any, "Arial", 12)

Global FPS

; Initialisation de l'environnement 3D
If InitEngine3D(#PB_Engine3D_DebugLog) = 0 Or InitSprite() = 0  Or InitKeyboard() = 0 Or InitMouse() = 0
  MessageRequester("Information", "Souci d'initialisation environnement 3D")
EndIf

drx = DesktopResolutionX()
dry = DesktopResolutionY()

ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "", #PB_Window_Maximize | #PB_Window_BorderLess)
OpenWindowedScreen(WindowID(0),0, 0, WindowWidth(0)*drx , WindowHeight(0)*dry, 0, 0, 0, #PB_Screen_WaitSynchronization) 

InitScreenGadgets()

ButtonScreenGadget(#clickMe, 10, 10, 100, 50, "Click Me")

OpenScreenWindow(#win3d, 10 ,50 ,300, 530,"OpenScreenWindow")

; Clavier international
KeyboardMode(#PB_Keyboard_International | #PB_Keyboard_AllowSystemKeys)

; Camera
CreateCamera(0, 0, 0, 100, 100)
CameraBackColor(0, RGB(0, 139, 139))
MoveCamera(0, 3, 6, 10, #PB_Absolute)
CameraLookAt(0, 0, 0, 0)

; Light
AmbientColor(RGB(255, 165, 0))
CreateLight(0, $ffffff, -5, 10, 10)

; Un cube
CreateCube(0, 1)
CreateEntity(0, MeshID(0), #PB_Material_None)

;- Création du sprite Help
Bottom = CreateSprite(#PB_Any, ScreenWidth(), 150, #PB_Sprite_AlphaBlending)
If StartDrawing(SpriteOutput(Bottom))
  DrawingFont(FontID(FontInfo))
  DrawingMode(#PB_2DDrawing_AlphaChannel)
  Box(0, 0, ScreenWidth(), SpriteHeight(Bottom), RGBA(0, 0, 0, 140))
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(10, 10, ". : : Help : : .")
  DrawText(10, 40, "Touche Escape pour quitter.")
  StopDrawing()
EndIf 

; Boucle evenementielle
Repeat
  ; Traiter les évenement windows de la file d'attente
  While WindowEvent():Wend
  
  ; Traiter les evenements ScreenWindow
  If ScreenWindowEvent() = #PB_Event_Gadget
    Select EventScreenGadget()
      Case #clickMe
        Debug "Bouton clickMe sélectionné"
      EndSelect
  EndIf 
  
  ; Evenements 2D/3D
  ExamineKeyboard()
  ExamineMouse()  
  
  ; Rendu 3D
  RenderWorld()
  
  ; Rendu 2D
  DisplayTransparentSprite(Bottom, 0, ScreenHeight()-SpriteHeight(Bottom))
  
  ; Rendu screengadgets
  RenderScreenGadgets()
  
  ; Basculement ancienne image / nouvelle image du rendu final
  FlipBuffers() 
Until KeyboardPushed(#PB_Key_Escape)
A pripris, je pense que le dernier identifiant ScreenGadget sélectionné n'est pas libéré quand le focus n'est plus sur le gadget.

J'ai testé le code de test ScreenGadgetMultipleWindow.pb se trouvant dans les exemples de PureBasic et je rencontre ce souci quel que soit le screengadget.

Re: ScreenGadget : Souci identifiant

Publié : mer. 08/oct./2025 15:26
par SPH
Hier, j'ai lu plein de posts sur le forum anglais. Et ton problème a apparement été rencontré par d'autres également. Si je me rappelle bien, il y a encore pas mal de boulot pour cette nouvelle bibliothèque.

Donc, patience (tout en faisant remonter) :idea:

Re: ScreenGadget : Souci identifiant

Publié : mer. 08/oct./2025 15:42
par Guillot
ouai
j'ai signalé ce bug
quand on clic sur une zone "neutre", le dernier gadget (ou window) selectionné recoit le clic
il me l'on trouvé sur le forum english !