Skip to content

Commit 8d0f745

Browse files
committed
Highlight clicked button
1 parent be0c7c4 commit 8d0f745

2 files changed

Lines changed: 35 additions & 4 deletions

File tree

audioswitcher.pb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ Repeat
8888
BevelButton::Enable(ButtonVolumes2)
8989
BevelButton::Disable(ButtonVolumes1)
9090
EndSelect
91+
; Dark button
92+
If BevelButton::GetButton(EventGadget())
93+
BevelButton::ColorDark(BevelButton::GetButton(EventGadget()))
94+
EndIf
9195
LockWindowUpdate_(0)
9296
UpdateWindow_(WindowID(WindowMain))
9397

@@ -107,6 +111,11 @@ Repeat
107111
SoundDevice("SetVolume", Config$(Config$("lastDevice") + "Speaker"), Config$(Config$("lastDevice") + Config$("lastVolume") + "Value"), True)
108112
EndSelect
109113

114+
; Finished setting
115+
If BevelButton::GetButton(EventGadget())
116+
BevelButton::ColorNormal(BevelButton::GetButton(EventGadget()))
117+
EndIf
118+
110119
EndSelect
111120
Until Event = #PB_Event_CloseWindow
112121
HideWindow(WindowMain, #True)
@@ -129,7 +138,7 @@ Procedure SoundDevice(Command$, Device$, Param$ = "", Wait = #False)
129138
allParams$ = "/" + Command$ + " " + Chr(34) + Device$ + Chr(34) + " " + Param$
130139
; Flags
131140
Flags = 0
132-
If Wait = True
141+
If Wait = #True
133142
Flags = #PB_Program_Wait
134143
EndIf
135144
; Run SoundVolumeView
@@ -174,7 +183,7 @@ Procedure WritePreference(Key$, Device$)
174183
ClosePreferences()
175184
EndProcedure
176185

177-
; IDE Options = PureBasic 5.72 (Windows - x86)
186+
; IDE Options = PureBasic 5.73 LTS (Windows - x86)
178187
; CursorPosition = 61
179188
; FirstLine = 21
180189
; Folding = -

bevelbutton.pb

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@ DeclareModule BevelButton
77
height.i
88
text.s
99
font.i
10+
color.i
1011
EndStructure
1112

13+
Global NewMap Gadget2BevelButton()
14+
1215
Declare New(x, y, width, height, image, text.s, font = 0, flags = 0)
1316
Declare Delete(*button.button)
1417
Declare Redraw(*button.button)
1518
Declare Enable(*button.button)
19+
Declare ColorDark(*button.button)
20+
Declare ColorNormal(*button.button)
1621
Declare Disable(*button.button)
1722
Declare GetGadgetID(*button.button)
1823
Declare SetText(*button.button, text.s, font = 0)
1924
Declare.s GetText(*button.button)
2025
Declare SetFont(*button.button, font)
26+
Declare GetButton(gadget)
2127
EndDeclareModule
2228

2329
Module BevelButton
@@ -29,8 +35,10 @@ Module BevelButton
2935
*button\height = height
3036
*button\font = font
3137
*button\text = text
38+
*button\color = RGB(0, 255, 0)
3239

3340
Redraw(*button)
41+
Gadget2BevelButton(Str(*button\gadget)) = *button
3442
ProcedureReturn *button
3543
EndProcedure
3644

@@ -43,7 +51,7 @@ Module BevelButton
4351

4452
; Button state
4553
If GetGadgetState(*button\gadget) = #True
46-
color = RGB(0, 255, 0)
54+
color = *button\color
4755
Else
4856
color = GetSysColor_(#COLOR_BTNFACE)
4957
EndIf
@@ -69,6 +77,16 @@ Module BevelButton
6977
Redraw(*button)
7078
EndProcedure
7179

80+
Procedure ColorDark(*button.button)
81+
*button\color = RGB(0, 150, 0)
82+
Redraw(*button)
83+
EndProcedure
84+
85+
Procedure ColorNormal(*button.button)
86+
*button\color = RGB(0, 255, 0)
87+
Redraw(*button)
88+
EndProcedure
89+
7290
Procedure Disable(*button.button)
7391
SetGadgetState(*button\gadget, #False)
7492
Redraw(*button)
@@ -92,6 +110,10 @@ Module BevelButton
92110

93111
Procedure SetFont(*button.button, font)
94112
*button\font = font
95-
Redraw(*button)
113+
Redraw(*button)
114+
EndProcedure
115+
116+
Procedure GetButton(gadget)
117+
ProcedureReturn Gadget2BevelButton(Str(gadget))
96118
EndProcedure
97119
EndModule

0 commit comments

Comments
 (0)