@@ -20,13 +20,32 @@ func (v TestView) keyDown(event appkit.Event) {
2020 log .Println ("Keydown:" , v .Class ().Name (), event .Class ().Name ())
2121}
2222
23+ func (v TestView ) dividerThickness () float64 {
24+ return 10.0
25+ }
26+
27+ func (v TestView ) dividerColor () appkit.Color {
28+ return appkit .Color_BlackColor ()
29+ }
30+
2331func main () {
2432 log .Println ("Program started." )
2533
26- c := objc .AllocateClass (objc .GetClass ("NSView" ), "TestView" , 0 )
27- objc .AddMethod (c , objc .Sel ("acceptsFirstResponder" ), (TestView ).acceptsFirstResponder )
28- objc .AddMethod (c , objc .Sel ("keyDown:" ), (TestView ).keyDown )
29- objc .RegisterClass (c )
34+ // Create a SplitView subclass using AllocateClass
35+ SplitViewClass := objc .AllocateClass (objc .GetClass ("NSSplitView" ), "TestSplitView" , 0 )
36+ objc .AddMethod (SplitViewClass , objc .Sel ("acceptsFirstResponder" ), (TestView ).acceptsFirstResponder )
37+ objc .AddMethod (SplitViewClass , objc .Sel ("keyDown:" ), (TestView ).keyDown )
38+
39+ // Implement these methods for the dividerThickness and dividerColor properties on the subclass
40+ objc .AddMethod (SplitViewClass , objc .Sel ("dividerThickness" ), (TestView ).dividerThickness )
41+ objc .AddMethod (SplitViewClass , objc .Sel ("dividerColor" ), (TestView ).dividerColor )
42+
43+ objc .RegisterClass (SplitViewClass )
44+
45+ ViewClass := objc .AllocateClass (objc .GetClass ("NSView" ), "TestView" , 0 )
46+ objc .AddMethod (ViewClass , objc .Sel ("acceptsFirstResponder" ), (TestView ).acceptsFirstResponder )
47+ objc .AddMethod (ViewClass , objc .Sel ("keyDown:" ), (TestView ).keyDown )
48+ objc .RegisterClass (ViewClass )
3049
3150 app := appkit .Application_SharedApplication ()
3251
@@ -45,7 +64,18 @@ func main() {
4564 win .SetTitle ("Hello world" )
4665 win .SetLevel (appkit .MainMenuWindowLevel + 2 )
4766
48- view := appkit .ViewFrom (c .CreateInstance (0 ).Ptr ()).InitWithFrame (frame )
67+ view := appkit .SplitViewFrom (SplitViewClass .CreateInstance (0 ).Ptr ()).InitWithFrame (frame )
68+ view .SetVertical (true )
69+
70+ neatView := appkit .ViewFrom (ViewClass .CreateInstance (0 ).Ptr ()).InitWithFrame (rectOf (0 , 0 , 150 , 99 ))
71+ coolView := appkit .ViewFrom (ViewClass .CreateInstance (0 ).Ptr ()).InitWithFrame (rectOf (10 , 0 , 150 , 99 ))
72+ neatView .AddSubview (appkit .NewLabel ("NEAT" ))
73+ coolView .AddSubview (appkit .NewLabel ("COOL" ))
74+
75+ // Add subviews
76+ view .AddArrangedSubview (neatView )
77+ view .AddArrangedSubview (coolView )
78+
4979 win .SetContentView (view )
5080 win .MakeKeyAndOrderFront (nil )
5181
0 commit comments