6 X11BaseWindow subclass: X11Button [
7 | text hovered wasPress enabled normback hoverback |
9 ^new: parent at: xy size: sz text: aText [
11 obj := self new: parent at: xy size: sz bgColor: (X11Color new: 0 g: 0 b: 0.7).
12 self in: obj var: #text put: aText.
13 obj; fontColor: 1.0 g: 1.0 b: 1.0; show.
17 ^new: parent at: xy text: aText [
19 obj := self new: parent at: xy size: 1 @ 1 text: aText.
21 gw := font textWidth: aText.
22 gh := font textHeight: aText.
23 obj resize: (gw + 12) @ (gh + 8).
29 normback := X11Color new: 0.0 g: 0.0 b: 0.7.
30 hoverback := X11Color new: 0.0 g: 0.0 b: 0.9.
45 self fgColor: (hovered ifNotNil: [ hoverback ] ifNil: [ normback ]).
46 rc := (self clientRect) growX: 1 y: 1.
49 wasPress ifNotNil: [ tpt := tpt moveX: 1 y: 1 ].
50 self drawTextAt: tpt text: text.
57 onX11EnterNotify: evt [
62 onX11LeaveNotify: evt [
63 hovered := wasPress := nil.
67 onX11ButtonPress: evt [
68 (evt at: 8) = 1 ifTrue: [ wasPress := true. self draw. ].
71 onX11ButtonRelease: evt [
72 ((wasPress notNil) and: [ (evt at: 8) = 1 ]) ifTrue: [