Strange Colour Requester behaviour

Just starting out? Need help? Post your questions and find answers here.
KianV
User
User
Posts: 16
Joined: Thu Dec 26, 2019 3:31 pm

Strange Colour Requester behaviour

Post by KianV »

Hi all,
I have a program which uses a colour requester, but it is exhibiting some rather odd behaviour.
The relevant piece of code is below:

Code: Select all

If OpenWindow(0, 100, 50, 120, 120, "Colour Requester Test")
  CreateImage(1, 20, 20 ,32 ,RGB(255,255,255));blank imagefor title colour
  ImageGadget(2, 50, 50, 20, 20, ImageID(1),#PB_Image_Border)  ;image for title colour 
  Repeat
    Event=WaitWindowEvent()
    Select EventGadget()     
      Case 2
        Colour = ColorRequester(subtitlecolour)   
    EndSelect
  Until  Event = #PB_Event_CloseWindow  
EndIf
This heavily trimmed version doesn't actually do anything to the image gadget, but once the requester is used, just moving the mouse pointer over the image will re-open the requester.
(Note:this only happens on alternate uses - i.e. once used after it has opened itself, the next movement of the mouse over the image will not trigger the requester opening.)
I have managed to trap the error,(when the Event_Type is either #PB_EventType_Dragstart or -1), but am curious to know what exactly is happening.
All insights gratefully received.
Kian
infratec
Always Here
Always Here
Posts: 7618
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Strange Colour Requester behaviour

Post by infratec »

You are missing the event type on which is triggered.

Code: Select all

If OpenWindow(0, 100, 50, 120, 120, "Colour Requester Test")
  CreateImage(1, 20, 20 ,32 ,RGB(255,255,255));blank imagefor title colour
  ImageGadget(2, 50, 50, 20, 20, ImageID(1),#PB_Image_Border)  ;image for title colour
  Repeat
    Event=WaitWindowEvent()
    Select EventGadget()     
      Case 2
        If EventType() = #PB_EventType_LeftClick
          Colour = ColorRequester(subtitlecolour)
        EndIf
    EndSelect
  Until  Event = #PB_Event_CloseWindow 
EndIf
KianV
User
User
Posts: 16
Joined: Thu Dec 26, 2019 3:31 pm

Re: Strange Colour Requester behaviour

Post by KianV »

Such a silly thing to miss.
Thanks a lot, infratec :D
Post Reply