within UKWindow a class derived from NSWindow I use the follwing code:
- Code: Select all
Dim theSubviews As Array
Dim currentSubview As NSView
Dim theImageViews As Array
Dim currentImageView As NSImageView
' Dim theObject As NSObject
Dim counter As Integer
Dim numberOfSubviews As Integer
Dim images As Array("erdmann.jpg", "wein.jpg")
Dim player1View As NSView
' Declare Delegate "NSView" - (void)mouseDown:(NSEvent *)event sender:(id)control
Declare Function "NSEvent" - (NSPoint)locationInWindow
Declare Sub "NSView" - (void)setDelegate:(id)del
Event AwakeFromNib()
numberOfSubviews = 4
' theMainView.Delegate = Me
' Me.Delegate=Me
For counter = 0 To numberOfSubviews-1
currentSubview = NSView()
currentSubview.setFrame(Rect(50+(counter*110),50,100,100))
theSubviews.Append(currentSubview)
currentImageView = NSImageView(images.Object(counter Mod 2))
' currentImageView.ImageScaling = 1
currentImageView.setFrame(Rect(0, 0, 100, 100))
Log(images.Object(counter Mod 2))
theImageViews.Append(currentImageView)
currentSubview.addSubview(currentImageView)
' currentSubview.Delegate = Me ' << offendig line
theMainView.addSubview(currentSubview)
Next
player1View = NSView()
player1View.setFrame(Rect(450, 300, 100, 100))
theMainView.addSubview(player1View)
End Event
With "currentSubview.Delegate = Me" I want to assign the same event handler for all subviews within the main view. Could you please give a hint, how to handle this.
Thanks
Udo