It is currently Thu Apr 02, 2020 10:48 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: bug,SetGadgetText(#ComboBox_1,s.s)
PostPosted: Thu Sep 07, 2017 6:23 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3648
Location: Utah, USA
kenmo wrote:
Definitely a bug.
Though I think it's a GetGadgetText() bug, not a SetGadgetText() bug.

Here, GetGadgetText() is returning an old string "1" when the gadget clearly shows "2".
PB 5.60 x86 on Windows 7

I can confirm the behavior.

GetGadgetText() changes its behavior in an editable ComboBox gadget once an item is selected from the drop-down list.

In its initial state the ComboBox retrieves the text displayed in editable area of the ComboBox when GetGadgetText() is used.

After an item is selected from the drop-down list it, GetGadgetText() seems to function identical to GetGadgetItemText(#, GetGadgetState(#)).

This behavior can be flipped again by entering text in the editable area of the ComboBox.

@kenmo: This can be seen on your example as well. After following the steps displayed in your code type a "1" or anything else in the ComboBox and press the button again a few times.


I'm not sure but SetGadgetState() seems like it may be generating events that also need to be dealt with before retrieving the text with GetGadgetState().

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: bug,SetGadgetText(#ComboBox_1,s.s)
PostPosted: Wed Sep 13, 2017 9:36 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 611
Location: china
ok,for win pb5.61:
Code:
;ok,for win pb5.61
OpenWindow(0,0,0,300,100,"",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
LoadFont(0,"system", 12):SetGadgetFont(#PB_Default, FontID(0))
ComboBoxGadget(0, 5, 5, 80, 25, #PB_ComboBox_Editable)
AddGadgetItem(0,-1,"100")
AddGadgetItem(0,-1,"200")
ButtonGadget(1, 85, 0,200, 25, "Button 1")
; TextGadget(2, 99, 35, 70, 25, "")
; TextGadget(3, 30, 35, 70, 25, "")
; SetGadgetState(0,0)
; g0=GetGadgetState(0)
; SetGadgetText(3,""+g0)
Repeat:ev=WaitWindowEvent():Select ev
  Case #PB_Event_Gadget:eg=EventGadget()
   Select eg
;     Case 0:g0=GetGadgetState(0)
;      SetGadgetText(3,""+g0)
    Case 1:g0s.s=Str(1+Val(GetGadgetText(0)))
     SetActiveGadget(0)
     keybd_event_(#VK_SPACE,0,0,0)
     keybd_event_(#VK_SPACE,0,#KEYEVENTF_KEYUP,0)
     keybd_event_(#VK_BACK,0,0,0)
     keybd_event_(#VK_BACK,0,#KEYEVENTF_KEYUP,0)
     SetGadgetText(0,g0s)
     ;SetGadgetText(2,g0s)
     AddGadgetItem(0,-1,g0s)
;      g0=GetGadgetState(0)
;      SetGadgetText(3,""+g0)
   EndSelect
  Case #PB_Event_CloseWindow:Break
EndSelect:ForEver
End

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
 Post subject: Re: bug,SetGadgetText(#ComboBox_1,s.s)
PostPosted: Thu Sep 14, 2017 4:53 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 611
Location: china
if not use (Input or keybd_event[can't use delete]),
will is bug or wrong.
because if GetGadgetState(0)>-1, edit Editable will confused
but Input or keybd_event can let GadgetState(0)=-1
but before edit, can't use SetGadgetState(0,-1)

other, if GetGadgetState(0)>-1, SetGadgetText(0,GetGadgetText(0))
will not change GadgetState(0)

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
 Post subject: Re: bug,SetGadgetText(#ComboBox_1,s.s)
PostPosted: Fri Nov 30, 2018 6:17 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 611
Location: china
If use #PB_ComboBox_Editable
will add a edit gadget, see try
now known,maybe
ComboBoxGadget Not can use SetGadgetText()
because when Not use #PB_ComboBox_Editable,ComboBoxGadget's text change by list
-------------
when use #PB_ComboBox_Editable,ComboBoxGadget's text change by list or edit gadget
by set edit gadget's text ,will is right set ComboBoxGadget's text

try:
Code:
Handle=OpenWindow(0, 0, 0, 270, 180, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ComboBoxGadget(0, 10, 10, 250, 21, #PB_ComboBox_Editable)
ComboBoxGadget(1, 10, 40, 250, 21)

Procedure ListWindows(hwnd,Param)
 Protected String$ = Space(250)
 Protected Class$ = Space(1024)
 GetWindowText_(hwnd,@String$,250)
 GetClassName_(hwnd,@Class$,Len(Class$))
 Debug Class$+":"+String$
 ProcedureReturn #True
EndProcedure

EnumChildWindows_(Handle,@ListWindows(),0)

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
 Post subject: Re: bug,SetGadgetText(#ComboBox_1,s.s)
PostPosted: Fri Nov 30, 2018 12:01 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 611
Location: china
this see the edit gadget's text and ComboBoxGadget's text to set
Code:
Handle=OpenWindow(0, 0, 0, 270, 180, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
hh=ComboBoxGadget(0, 10, 10, 250, 21, #PB_ComboBox_Editable)
AddGadgetItem(0, -1, "ComboBox editable...")
s.s="kkkkk"
;SetGadgetText(0,s)
Debug GetGadgetState(0)
ComboBoxGadget(1, 10, 40, 250, 21)
Global h
Procedure ListWindows(hwnd,Param)
 Protected String$ = Space(250)
 Protected Class$ = Space(1024)
 GetWindowText_(hwnd,@String$,250)
 GetClassName_(hwnd,@Class$,Len(Class$))
 Debug Class$+":"+String$
 If Class$ ="Edit"
 h=hwnd:EndIf
 ProcedureReturn #True
EndProcedure

EnumChildWindows_(Handle,@ListWindows(),0)
SendMessage_(h,#EM_REPLACESEL,0,s)
Debug GetGadgetState(0)
Debug h
Debug hh
EnumChildWindows_(Handle,@ListWindows(),0)
Debug GetGadgetState(0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
 Post subject: Re: bug,SetGadgetText(#ComboBox_1,s.s)
PostPosted: Wed Jan 09, 2019 3:27 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 611
Location: china
;ok, if use #PB_ComboBox_Editable And SetGadgetText()
;should do this:

Code:
;ok, if use #PB_ComboBox_Editable And SetGadgetText()
;should do this:
OpenWindow(0,0,0,300,100,"",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
LoadFont(0,"system", 12):SetGadgetFont(#PB_Default, FontID(0))
ComboBoxGadget(0, 5, 5, 80, 25, #PB_ComboBox_Editable)
AddGadgetItem(0,-1,"100")
AddGadgetItem(0,-1,"200")

ButtonGadget(1, 85, 0,200, 25, "test")
SetGadgetState(0,0)

Repeat:ev=WaitWindowEvent():Select ev
  Case #PB_Event_Gadget:eg=EventGadget()
   Select eg
    Case 1
     s.s=Str(1+Val(GetGadgetText(0)))
     If GetGadgetState(0)>-1
      SetGadgetState(0,-1)
     EndIf
     SetGadgetText(0,s)
   EndSelect
   
  Case #PB_Event_CloseWindow:Break
EndSelect:ForEver
End

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
 Post subject: Re: bug,SetGadgetText(#ComboBox_1,s.s)
PostPosted: Sun Mar 10, 2019 10:54 am 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5797
Location: Germany
fixed.

_________________
quidquid Latine dictum sit altum videtur


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


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