It is currently Tue Sep 17, 2019 8:33 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [Done] OptionGadget
PostPosted: Tue Apr 02, 2019 3:06 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 447
In this example, GetGadgetState always returns 1 even if the OptionGadget isn't selected.

Works fine on Linux.
Code:
Enumeration
  #Window
  #Option1
  #Option2
EndEnumeration

Procedure OnOption()
  Debug GetGadgetState(#Option1)
  Debug GetGadgetState(#Option2)
EndProcedure

OpenWindow(#Window, 0, 0, 250, 150, "Window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget)
OptionGadget(#Option1, 10, 10, 230, 20, "One")
OptionGadget(#Option2, 10, 35, 230, 20, "Two")
SetGadgetState(#Option1, 1)
BindGadgetEvent(#Option1, @OnOption())
BindGadgetEvent(#Option2, @OnOption())

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject: Re: OptionGadget
PostPosted: Tue Apr 02, 2019 4:35 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1903
Location: Germany
The event comes too early with some changes. This includes #PB_EventType_Resize.
If you delay the event by one cycle, the data from the gadget is also updated and valid.
Unfortunately there is still a bug...

Solution
Code:
Enumeration
  #Window
  #Option1
  #Option2
EndEnumeration

#EventDataID = $FFFFAAAA

Procedure ResumeGadgetEvents()
  If EventData() <> #EventDataID
    PostEvent(#PB_Event_Gadget, EventWindow(), EventGadget(), EventType(), #EventDataID)
  EndIf
EndProcedure

BindEvent(#PB_Event_Gadget, @ResumeGadgetEvents())

Procedure OnOption()
  If EventData() = #EventDataID
    Debug GetGadgetState(#Option1)
    Debug GetGadgetState(#Option2)
  EndIf
EndProcedure

OpenWindow(#Window, 0, 0, 250, 150, "Window", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget)
OptionGadget(#Option1, 10, 10, 230, 20, "One")
OptionGadget(#Option2, 10, 35, 230, 20, "Two")
SetGadgetState(#Option1, 1)
BindGadgetEvent(#Option1, @OnOption())
BindGadgetEvent(#Option2, @OnOption())

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: OptionGadget
PostPosted: Thu Apr 04, 2019 11:24 am 
Offline
User
User

Joined: Mon Jul 17, 2017 7:22 am
Posts: 58
Location: Cotswolds England
Am I missing something here?
There isn't anything else to choose on the screen and the OptionGadget appears to me to be working just fine & returning the correct results.

(just noticed it is in Mac OSX, I refer to Windows only, so can't really comment :oops: )

_________________
If it's falling over......just remember the computer is never wrong!


Top
 Profile  
Reply with quote  
 Post subject: Re: OptionGadget
PostPosted: Thu Apr 04, 2019 3:23 pm 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1671
Location: Uttoxeter, UK
@wombats,
Works fine on Windows, too.
However, I confirm your results on my MacBook.
I think you are right to post this as a bug; it should work the same way on all OSs without the need of very clever work-arounds.
A bug like this would cause me to spend ages trying to determine 'what I had done wrong'. Thank you for discovering it.

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: OptionGadget
PostPosted: Fri Apr 12, 2019 1:16 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13612
Location: France
Fixed.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye