Delegate doesn't compile
Posted: Wed Dec 22, 2010 7:13 pm
Bernd,
please have a look:
The compiler states
When replacing AsRef with As the problem persists.
Regards
Udo
please have a look:
- Code: Select all
Declare Function "NSTextView" - (NSRange)selectedRange
Declare Sub "NSTextView" - (void)setSelectedRange:(NSRange)charRange
Declare Sub "NSTextView" - (void)complete:(id)sender
Declare Function "NSString" - (NSString *)substringWithRange:(NSRange)aRange
Declare Sub "NSTextView" - (void)startSpeaking:(id)sender
Declare Class "NSInteger"
Declare Delegate "NSTextView" - (NSArray *)textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index
IBOutlet theTextfield As NSTextField
' the music plays within the Events of the TextView - while processing thesse we can
' use the instance decoration at hand to appropriatly react to the Event
Event TextViewDidChangeSelection(theTextView As NSTextView)
Dim theRange As Range
Dim theString As NSString
Dim theSubString As NSString
Dim theLocation As Integer
theRange = theTextView.selectedRange()
' Log(theRange.Length)
' Log(theRange.Location)
' Log(theRange)
' Length only has a nonzero value if the user actually selects something
If(theRange.Length) Then
theString = theTextView.Value
theSubString = theString.substringWithRange(theRange)
theTextfield.StringValue=String(theSubString)
If (Contains(theSubString, "Huhn")) Then
' Notification.startSpeaking(Nil)
' if you like to append after the selected text just comment the following line out
theRange.Location = theRange.Location + theRange.Length
' theLocation=theRange.Location
' ' unselect range by setting its length to zero
theRange.Length = 0
'
theTextView.setSelectedRange(theRange)
' theTextView.Insert(" du bist ein ")
'
' theRange.Location=theLocation
' theTextView.setSelectedRange(theRange)
theTextView.complete(Nil)
' Else
' theTextfield.StringValue = ""
End If
End If
End Event
Event TextDidEndEditing(Notification As id)
Dim ra As Range
Alert("End Editing",Notification)
End Event
'Event ShouldChangeText(ar As Array, Dummy As id)
' Alert(ar)
'End Event
Event MouseDown(theEvent As NSEvent)
Alert(theEvent)
End Event
' if I use the KeyDown Event the character seems to be eleminated from the input buffer before
' the TextView actually sees it - it appears just as I have entered nothing i.e. pressed no key
' at all
Event KeyUp(theEvent As NSEvent)
Log(theEvent.Characters())
End Event
Delegate textView(textView As NSTextView, words As Array, charRange As Range, index AsRef Integer) As NSArray
Log(words)
Return(Array("Katze","Maus"))
End Delegate
Event AwakeFromNib()
Me.Delegate=Me
End Event
The compiler states
- Code: Select all
/Users/HU/Desktop/ObjectiveBasic/ukTextView/Build/Release/ObjC/UKTextView.mm: In function 'NSArray* -[UKTextView textView:completions:forPartialWordRange:indexOfSelectedItem:](UKTextView*, objc_selector*, NSTextView*, NSArray*, NSRange, NSInteger*)':
/Users/HU/Desktop/ObjectiveBasic/ukTextView/Build/Release/ObjC/UKTextView.mm:81: error: call of overloaded 'NSOBJECT(NSInteger*&)' is ambiguous
compilation terminated due to -Wfatal-errors.
When replacing AsRef with As the problem persists.
Regards
Udo