Menu

check boxes

2020-11-01
2020-11-08
  • John Duchek

    John Duchek - 2020-11-01

    Hi Stabud,
    I am running this example program from the documentation.

    Include "window9.bi"

    Dim As integer hwnd,event
    hwnd=OpenWindow("1",300,10,500,500)
    OptionGadget(1,10,10,100,30,"option 1")
    OptionGadget(2,10,40,100,30,"option 2")
    TextGadget(3,100,30,100,30,"Бу-га-га")
    Do
    event=WaitEvent()
    If event=EventClose Then End
    If event=eventgadget Then
    If GetGadgetState(1)=1 Then
    setgadgettext(3,"1 option")
    ElseIf GetGadgetState(2)=1 Then
    setgadgettext(3,"2 option")
    EndIf
    EndIf
    Loop

    and it is not working right, and I cannot figure out why. If option one is clicked, the textgadget says option 2 and if option 2 is clicked it says option 1. I expanded it to 3 options and it is still goofy.

    Include "window9.bi"

    Dim As integer hwnd,event
    hwnd=OpenWindow("1",300,10,500,500)
    OptionGadget(1,10,10,100,30,"option 1")
    OptionGadget(2,10,40,100,30,"option 2")
    OptionGadget(3,10,70,100,30,"option 3")
    TextGadget(4,100,30,100,30,"test")

    Do
    event=WaitEvent()
    If event=EventClose Then End

    If event=eventgadget Then

    If GetGadgetState(1)=1 Then
    setgadgettext(4,"1")
    ElseIf GetGadgetState(2)=1 Then
    setgadgettext(4,"2")
    elseif GetGadgetState(3)=1 then
    setgadgettext(4,"3")
    EndIf
    EndIf
    Loop

    I click on option 2 and the text gadget says 1,option 3 says option 2, and option 1 says 3. Can you see an error in the original example that would cause this behavior?
    Thanks for any help, (running under fedora linux)
    John

     
  • stabud

    stabud - 2020-11-01

    The help says (Please translate this sentence yourself into your native language.):

    При клике по CheckBoxGadget , в Windows сначала меняется состояние гаджета, а потом отправляется событие окну о клике мышкой по гаджету, в Linux наоборот.


    The GetGadgetState function is needed to determine the state of the gadget in case of events with other gadgets. For example, by clicking on ButtonGadget, you can find out in its click event the current state of CheckBoxGadget (as it is in the help example)

    If you need to find out the CheckBoxGadget number when you click on it, then:

    #include "window9.bi"
    
    Dim As long event
    OpenWindow("1",300,10,500,500)
    OptionGadget(1,10,10,100,30,"option 1")
    OptionGadget(2,10,40,100,30,"option 2")
    TextGadget(3,100,30,100,30,"Бу-га-га")
    Do
        event=WaitEvent()
        If event=EventClose Then End
        If event=eventgadget Then
            select case eventnumber     
                Case 1 to 2         
                    setgadgettext(3, eventnumber & " option")           
            End Select
        EndIf
    Loop
    
     
  • John Duchek

    John Duchek - 2020-11-02

    Thank you for your answer and your help. Trying to have software that works for multiple OSs has to be a pain. Thanks for your efforts,
    John

     
  • John Duchek

    John Duchek - 2020-11-08

    I have one more question on check boxes. Again running linux, my program with 3 checkboxes is running. I notice that I am getting a repeated an error message in the terminal. A set of 11 identical messages appear each time I change the check boxes(there are 3 choices). It is:
    (English_to_Metric_Converter:7364): Gtk-CRITICAL **: 07:26:00.356: IA__gtk_widget_modify_font: assertion 'GTK_IS_WIDGET (widget)' failed

    There are no messages before I press a checkbox change. I have 14 buttons working with text.
    I am using the default font so I do not get what this is trying to tell me. I would appreciate your comments on what this error message means. These error messages do not affect the program capability to run so it may be a warning, not an error. Thanks for any help,
    John

     
  • stabud

    stabud - 2020-11-08

    Please post the minimum possible code in which you receive this error.

     
    • John Duchek

      John Duchek - 2020-11-08

      I can see it has something to do with the button gadgets. I cut the number of buttons down to 1 and I get the error once each time I change the checkbox. Thanks,
      John

      Include "window9.bi"

      '------display------------------

      dim shared as integer xxsize, yysize,num_monitors,i
      dim shared as integer col1,col2,col3,row1,row2,row3
      dim shared as integer monitor(2,2),choice
      Dim shared As integer but,event,dimensions
      dim shared as integer xcenter2,ycenter2,xsize,ysize,indx
      dim shared as string metric_text,unit(20,3),mil
      dim shared as single convert(20,3)
      dim shared as single metric_ans,english_quest
      '--------------------------------
      col1=100:row1=1
      col2=100:row2=261
      dimensions=1
      xsize=800
      ysize=500
      xcenter2=1
      ycenter2=1
      OpenWindow("Convert English to Metric",xcenter2,ycenter2,xsize,ysize)
      ButtonGadget(1,261,1,260,30,unit(1,dimensions))

      OptionGadget(31,10,30,100,30,"Set 1")
      OptionGadget(32,10,50,100,30,"Set 2")
      OptionGadget(33,10,70,100,30,"Set 3")

      Do
      event=WaitEvent()
      If event=EventClose Then End

      Select Case event

      case EventGadget
      select case EventNumber
      case 1 to 16
      indx=EventNumber

              Case 31 to 33         
                  dimensions=EventNumber-30
                  for i=1 to 16
                  setgadgettext(i, unit(i,dimensions))           
                  next
      

      End Select

      End Select

      Loop

       
  • stabud

    stabud - 2020-11-08

    The setgadgettext function does not tolerate being sent a zero-length string. For example, you cannot do this: setgadgettext (gadget, ""). If you need to make the gadget empty, then you can do so setgadgettext (gadget, " "), or so setgadgettext (gadget, chr (0)).

     
  • John Duchek

    John Duchek - 2020-11-08

    Thank you, stabud. As I am writing this program I am filling those empty buttons, By the time I am done, there would have no longer been any empty ones. I was thinking that this thing would break at some point, but as I continue with the program those would have slowly gotten fewer. I really appreciate you looking at the code and helping me with the error.
    John

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.