Remove ButtonGadget border

Just starting out? Need help? Post your questions and find answers here.
Ross Carter
New User
New User
Posts: 3
Joined: Thu May 11, 2023 2:56 pm
Location: Portsmouth, Uk

Remove ButtonGadget border

Post by Ross Carter »

First time using PureBasic, and would like to know if it is possible to display a button using ButtonGadget with no border.

I would be grateful if anyone could help with this problem.
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Remove ButtonGadget border

Post by jacdelad »

Code from uwekel:

Code: Select all

If OpenWindow(0, 0, 0, 300, 200, "Borderless Button", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonGadget(0, 10, 10, 80, 40, "Test")
  gtk_button_set_relief_(GadgetID(0), 2)
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
...if you are on Linux. Since you didn't specify your OS...
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Remove ButtonGadget border

Post by Kiffi »

Possible but cumbersome (and possibly cross-platform):

Code: Select all

Enumeration
  #Window
  #Container
  #Button
EndEnumeration

If OpenWindow(#Window, 0, 0, 322, 150, "ButtonGadget without border", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ContainerGadget(#Container, 10, 10, 100, 100)
    ButtonGadget(#Button, -4, -4, 108, 108, "Button 1")
  CloseGadgetList()
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Hygge
Ross Carter
New User
New User
Posts: 3
Joined: Thu May 11, 2023 2:56 pm
Location: Portsmouth, Uk

Re: Remove ButtonGadget border

Post by Ross Carter »

Thanks for the code, jacdelad, and Kiffi, the code works fine for displaying only one button, but having a problem trying to display two buttons within the same window.

I would be grateful if anyone could help with this problem.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Remove ButtonGadget border

Post by RASHAD »

Hi Ross Carter
You can use HyperLinkGadget() instead
Or
If you are Windows User you can use TextGadget() with #SS_Notify
Or Owner Drawn Gadget
There are many alternative in this case

Code: Select all

OpenWindow(0, 0, 0, 270, 160, "HyperLinkButton", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  HyperLinkGadget(0, 10, 10, 80,22," Button #1",$0000FF)
  HyperLinkGadget(1, 10, 45, 80,22," Button #2",$00FF00)
  HyperLinkGadget(2, 10, 80, 80,22," Button #3",$FF0000)
  SetGadgetColor(0,#PB_Gadget_BackColor,$E8E9FE)
  SetGadgetColor(1,#PB_Gadget_BackColor,$E8FEEE)
  SetGadgetColor(2,#PB_Gadget_BackColor,$FEEEE8)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
           Quit = 1
           
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0,1,2
          Debug "Button "+Str(EventGadget())
      EndSelect
  EndSelect
Until Quit = 1
Egypt my love
Ross Carter
New User
New User
Posts: 3
Joined: Thu May 11, 2023 2:56 pm
Location: Portsmouth, Uk

Re: Remove ButtonGadget border

Post by Ross Carter »

Thanks RASHAD for your code, I never would have thought about using the HyperLinkGadget, it works fine.
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Remove ButtonGadget border

Post by Caronte3D »

Wow! Thi's a nice way of have colored button with mouseover effect :shock:
Another awesome trik from RASHAD :D
Post Reply