Gtk Button Theming 'suggested-action' and 'destructive-action'

New to Gambas? Post your questions here. No question is too silly or too simple.
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

Re: Gtk Button Theming 'suggested-action' and 'destructive-action'

Post by JumpyVB »

cogier wrote: Saturday 9th September 2023 9:16amThe best way is to make your own bespoke button.
Okay, I'll have a go with this. I will need to wrap this in to a custom control to keep the source code of FMain ungluttered. Let's leave out the label for now to make things more simple. So far I have created a "NiceButton.class":

' Gambas class file

Inherits Panel

Public Sub _New()
  Me.Background = Color.Black
End

Private Sub Me_MouseDown()
  Me.Background = Color.Red
End

Private Sub Me_Enter()
  Me.Background = Color.Yellow
End

Private Sub Me_Leave()
  Me.Background = Color.Black
End

Private Sub Me_MouseUp()
  Me.Background = Color.Black
End

Private Sub Me_GotFocus()
  Me.Border = Border.Dashed
End

Private Sub Me_LostFocus()
  Me.Border = Border.None
End


I have this in a new Graphical application with a single VBox on the FMain to populate my buttons (or a single button now for starters):
Public Sub Form_Open()
  PopulateGUI()
End

Private Button_Refresh As NiceButton
Private Sub PopulateGUI()
  With Button_Refresh = New NiceButton(VBox1) As "Button_Refresh"
    .Height = 28
    .Width = 120
  End With
End
Public Procedure Button_Refresh_Click()
  Me.Text = "It works!"
End
Only hovering the mouse cursor over my nice panel button or clicking it has no effect :( What am I doing wrong here?
User avatar
cogier
Site Admin
Posts: 1127
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Gtk Button Theming 'suggested-action' and 'destructive-action'

Post by cogier »

Have a look at ColButton that's on the farm and here.
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

Re: Gtk Button Theming 'suggested-action' and 'destructive-action'

Post by JumpyVB »

cogier wrote: Saturday 16th September 2023 2:41pm Have a look at ColButton that's on the farm and here.
Exactly what I needed. Thank you very much.
Post Reply