mirror of
https://github.com/Airr/nim-cocoa.git
synced 2024-11-24 09:45:30 +00:00
Added Cocoa Bindings Example
This commit is contained in:
parent
e9ba2931ed
commit
14c086d814
34
examples/bindtest.nim
Normal file
34
examples/bindtest.nim
Normal file
@ -0,0 +1,34 @@
|
||||
import Cocoa / [NSWindow, NSFunctions, NSCheckBox,
|
||||
NSTextField, NSSlider]
|
||||
|
||||
const
|
||||
winStyle = NSWindowStyleMaskTitled or NSWindowStyleMaskClosable
|
||||
|
||||
type
|
||||
GUI = object
|
||||
win: ID
|
||||
label: ID
|
||||
chk: ID
|
||||
slider: ID
|
||||
txt: ID
|
||||
|
||||
var self: GUI
|
||||
|
||||
Cocoa_Init()
|
||||
|
||||
self.win = newWindow("Cocoa Bindings Demo 1", 462, 128, winStyle)
|
||||
|
||||
self.chk = newCheckBox(self.win, "Enabled?", 18, 18, 78, 22) #iVar="state"
|
||||
self.txt = newTextField(self.win, "", 102, 18, 340, 22)
|
||||
self.slider = newSlider(self.win, 18, 48, 428, 19, nil) #iVar="Value"
|
||||
|
||||
# Bind TextBox and Slider value
|
||||
# Each can update the other
|
||||
self.txt.link("value",self.slider,"Value")
|
||||
self.slider.link("value", self.slider,"Value")
|
||||
|
||||
# Bind Checkbox and Slider state.
|
||||
# Checkbox controls enabled/disabled state of Slider!
|
||||
self.slider.link("enabled", self.chk,"state")
|
||||
|
||||
Cocoa_Run(self.win)
|
Loading…
Reference in New Issue
Block a user