buttyon, no reaction

Just starting out? Need help? Post your questions and find answers here.
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

buttyon, no reaction

Post by t57042 »

Code: Select all

If OpenWindow(0, 0, 0, 900, 600, "test",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )      
  
  EditorGadget(0,5,5,890,560,#PB_Editor_ReadOnly)         
  StringGadget(1, 15, 530, 790, 30, "") 
  ButtonGadget(2, 810, 530, 77, 30, "Enter")        
EndIf 

;====================================================================================

Repeat 
  Event = WaitWindowEvent() 
  
  Select Event 
    Case #PB_Event_Gadget 
        Select EventGadget() 
            Case 2 
                Debug "hiii" 
        EndSelect       
  EndSelect 

Until Event = #PB_Event_CloseWindow 
End
Why does the button in (simplified) code not react?
I must be overlooking something
thanks
Richard
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4662
Joined: Sun Apr 12, 2009 6:27 am

Re: buttyon, no reaction

Post by RASHAD »

Yes
PB does not support z-order
Your button overlapped the editor gadget

Code: Select all

If OpenWindow(0, 0, 0, 900, 600, "test",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered )     
 
  EditorGadget(0,5,5,890,520,#PB_Editor_ReadOnly)         
  StringGadget(1, 15, 530, 790, 30, "")
  ButtonGadget(2, 810, 530, 77, 30, "Enter")       
EndIf

;====================================================================================

Repeat
  Event = WaitWindowEvent()
 
  Select Event
    Case #PB_Event_Gadget
        Select EventGadget()
            Case 2
                Debug "hiii"
        EndSelect       
  EndSelect

Until Event = #PB_Event_CloseWindow
End
Egypt my love
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 543
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: buttyon, no reaction

Post by bbanelli »

t57042 wrote:Why does the button in (simplified) code not react?
I must be overlooking something
Because you can't "reach" your button (or string gadget, for that matter).

Change height parameter in EditorGadget() function to 520 or adjust other parameters of other gadgets accordingly and it will work as expected.
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

Re: buttyon, no reaction

Post by t57042 »

thanks guys
Richard
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: buttyon, no reaction

Post by chi »

RASHAD wrote:PB does not support z-order
Who told you that? ;) At least on Windows it work quite well...

But the sort-order is Top to Back! First gadget you create is on top and the following lies underneath (the complete opposite as one might think). So you just have to reverse your gadget order (ID doesn't matter), set the bottom gadget to WS_CLIPSIBLINGS and your are ready to go...

Code: Select all

If OpenWindow(0, 0, 0, 900, 600, "test",  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered ) 
  
  ButtonGadget(2, 810, 530, 77, 30, "Enter")       
  StringGadget(1, 15, 530, 790, 30, "")
  EditorGadget(0,5,5,890,560,#PB_Editor_ReadOnly) 
  SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) |#WS_CLIPSIBLINGS)  
      
EndIf

;====================================================================================

Repeat
  Event = WaitWindowEvent()
 
  Select Event
    Case #PB_Event_Gadget
        Select EventGadget()
            Case 2
                Debug "hiii"
        EndSelect       
  EndSelect

Until Event = #PB_Event_CloseWindow
End
Et cetera is my worst enemy
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4662
Joined: Sun Apr 12, 2009 6:27 am

Re: buttyon, no reaction

Post by RASHAD »

Who told you that? ;)
You are talking trash
I said PB does not support z-order not Windows API
Enlighten me more
Is there any command in PB for getting parent or ancestor of any object?
NO
Once more
PB does not support z-order
Why everybody in the forum all of the sudden became a lecturer teaching the others?
Egypt my love
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: buttyon, no reaction

Post by chi »

my bad :)
Et cetera is my worst enemy
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: buttyon, no reaction

Post by nco2k »

technically you could use UseGadgetList(GadgetID(0)) and add the other gadgets as children of the EditorGadget(). but its not a very good solution tbh. you could also use SetWindowPos_() with #HWND_TOP/BOTTOM etc. to change the z-order. but the best solution would be of course to not have any overlapping gadgets at all.

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Wolfram
Enthusiast
Enthusiast
Posts: 568
Joined: Thu May 30, 2013 4:39 pm

Re: buttyon, no reaction

Post by Wolfram »

I think is not a basic PB problem.
On OSX this code works.
macOS Catalina 10.15.7
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: buttyon, no reaction

Post by nco2k »

@Wolfram
iirc, gtk has/had problems with the z-order, so the team decided to not implement a z-order system at all.

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Post Reply