Page 1 of 1

Delegate doesn't compile

PostPosted: Wed Dec 22, 2010 7:13 pm
by udo.killermann
Bernd,

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.

ukTextView.zip
the project
(231.79 KiB) Downloaded 136 times


Regards
Udo

Re: Delegate doesn't compile

PostPosted: Thu Dec 23, 2010 10:35 am
by udo.killermann
if I replace (NSInteger *)index at the end of the delegate's signature with (NSInteger)index it works like it should - but I think this is quirky somehow.

Regards
Udo

Re: Delegate doesn't compile

PostPosted: Mon Jan 03, 2011 8:48 pm
by berndnoetscher
udo.killermann wrote:if I replace (NSInteger *)index at the end of the delegate's signature with (NSInteger)index it works like it should - but I think this is quirky somehow.

Regards
Udo


Happy new year!

Udo,
Will be on vacation a few days, after that I will create a fix for this. please be patient.

Re: Delegate doesn't compile

PostPosted: Wed Jan 05, 2011 7:19 am
by udo.killermann
Bernd,

happy new year for you as well. Enjoy your vacation - you deserve it.
I'll be patient and wait for your solution. I'll continue with the many features you have already implemented.

Kind regards
Udo