Page 1 of 1

StringGadget open a new window does not work

Posted: Wed Aug 08, 2012 8:45 am
by cajomi

Code: Select all

If OpenWindow(0,200,200,300,300,"Test")
  StringGadget(1,5,10,200,20,"testbutton",#PB_String_ReadOnly)
  
  Repeat
    Event = WaitWindowEvent()
    
    Select EventWindow() 
      Case 0       
        If Event = #PB_Event_CloseWindow  
          Quit = 1
        EndIf
        Select Event     
          Case #PB_Event_Gadget  
            Select EventGadget() 
              Case 1
                If IsWindow(1)
                Else 
                  OpenWindow(1,0,0,100,100,"Test2")
                  ButtonGadget(3,5,5,100,20,"close window")
                EndIf
            EndSelect
        EndSelect
      Case 1
        Select Event     
          Case #PB_Event_Gadget  
            Select EventGadget() 
              Case 3
                CloseWindow(1)
            EndSelect
        EndSelect
    EndSelect    
  Until Quit=1
EndIf
The code is ?
When you open it 1 time and close it, the window is still open.

Re: StringGadget open a new window does not work

Posted: Wed Aug 08, 2012 9:00 am
by Bisonte
If I click on the StringGadget(), the second window is shown, I click on the button and the second window dissapears.

So what is the behaviour you expect ?

Re: StringGadget open a new window does not work

Posted: Wed Aug 08, 2012 9:07 am
by cajomi
Open it once again,
1. open the window,
2. close window
3. open it again

that is the problem

Re: StringGadget open a new window does not work

Posted: Wed Aug 08, 2012 11:09 am
by falsam
Good morning.
Your stringgadget is ReadOnly.

When you focus the first time, an event is active and you open the window (#1).

The second time, you you have no event.

When you close your window (#1), I think in this case, you must have another gadget.

Your stringgadget (#1) will generate the event (#PB_EventType_Focus).

Code: Select all

If OpenWindow(0,200,200,300,300,"Test")
  StringGadget(0,5,10,200,20,"Nothing", #PB_String_ReadOnly)
  StringGadget(1,5,40,200,20,"testbutton", #PB_String_ReadOnly)
  
  Repeat
    Event = WaitWindowEvent()
    WEvent = EventWindow() 
    GEvent = EventGadget() 
    TEvent = EventType()
    
    Select Event
      Case #PB_Event_CloseWindow
        If WEvent = 0
          End
        EndIf
        
      Case #PB_Event_Gadget  
        Select GEvent
          Case 1  
            Select TEvent
              Case #PB_EventType_Focus
                If Not IsWindow(1)
                  OpenWindow(1,0,0,100,100,"Test2")
                  ButtonGadget(3,5,5,100,20,"close window")  
                EndIf
            EndSelect
            
          Case 3
            SetActiveWindow(0)
            SetActiveGadget(0)
            CloseWindow(1)
            
        EndSelect
    EndSelect
  ForEver
EndIf

Re: StringGadget open a new window does not work

Posted: Thu Aug 09, 2012 7:09 am
by cajomi
Thanks for help (by falsam)