Page 1 of 2
EditorGadGet
Posted: Mon Jul 21, 2014 8:56 pm
by spacebuddy
is there any way to move the cursor to a word in the EditorGadget??

Re: EditorGadGet
Posted: Tue Jul 22, 2014 5:53 am
by Danilo
What word do you want to move the cursor to? Next word? First occurrence of a specific word, like "Abc"? 2nd word on 3rd line?
You can set and get the cursor, you can set a selection, you can get the text, and more. Depending on your needs,
it is just a matter of some string scanning and setting the cursor. It is also important what 'word' means to you,
for example [a-z]|[A-Z] or _|[a-z]|[A-Z], followed by _|[a-z]|[A-Z]|[0-9], Greek alphabet, or Thai letters only?
奥地利(欧洲中部国家) = 오스트리아 = ออสเตรีย = Австрия = Αυστρία = Østerrike = Itävalta = République d'Autriche = Österreich = Austria

Re: EditorGadGet
Posted: Tue Jul 22, 2014 3:21 pm
by WilliamL
Re: EditorGadGet
Posted: Tue Jul 22, 2014 4:55 pm
by spacebuddy
yes, that works

Re: EditorGadGet
Posted: Sun Jul 27, 2014 6:45 pm
by spacebuddy
I am trying to check if an Editor Gadget has an attachment. This is the code I am using
Define exists.b
CocoaMessage(@exists, gadget, "containsAttachments")
But I get an invalid memory error
I think something wrong in my code

Re: EditorGadGet
Posted: Sun Jul 27, 2014 8:17 pm
by Danilo
Is 'gadget' the GadgetID()? What about defining 'exists' as .l or .i?
Re: EditorGadGet
Posted: Sun Jul 27, 2014 8:29 pm
by spacebuddy
Danilo,
Yes, gadget is the ID of the EditorGadget.
Re: EditorGadGet
Posted: Mon Jul 28, 2014 5:18 am
by wilbert
You need textStorage. Once you have the textStorage object, you can do a lot with that.
Code: Select all
textStorage = CocoaMessage(0, GadgetID(0), "textStorage")
Debug CocoaMessage(0, textStorage, "containsAttachments")
Re: EditorGadGet
Posted: Mon Jul 28, 2014 5:59 am
by spacebuddy
Thanks Wilbert

Re: EditorGadGet
Posted: Mon Jul 28, 2014 8:05 am
by spacebuddy
Oh, another problem I am having is zooming text in and out of editorGadget, I am using this code.
I am trying to access ScrollView to zoomScale, but I get an error
ScrollView = CocoaMessage(0,GadgetID(0),"ScrollView")
CocoaMessage(0, ScrollView, "zoomScale:@",2)
Re: EditorGadGet
Posted: Mon Jul 28, 2014 8:19 am
by wilbert
Try enclosingScrollView instead.
Edit: zoomScale also doesn't seem to exist. It might be more complicated.
It looks like you need scaleUnitSquareToSize: on the editor gadget itself.
Re: EditorGadGet
Posted: Mon Jul 28, 2014 8:41 am
by Danilo
Not that much complicated:
Code: Select all
size.NSSize
size\width = 5.0
size\height = 2.0
CocoaMessage(0,GadgetID(0),"scaleUnitSquareToSize:@",@size)
Re: EditorGadGet
Posted: Mon Jul 28, 2014 4:40 pm
by spacebuddy
Thanks Guys
Danilo, it works scaling, but when you want to make it smaller it does not work.
size\width = 1.5
size\height = 1.5
CocoaMessage(0,GadgetID(0),"scaleUnitSquareToSize:@",@size)
this will scale the text up, then if I do this
size\width = 1.0
size\height = 1.0
CocoaMessage(0,GadgetID(0),"scaleUnitSquareToSize:@",@size)
It does not scale back?
Re: EditorGadGet
Posted: Mon Jul 28, 2014 4:46 pm
by Danilo
Code: Select all
size.NSSize
size\width = 0.5
size\height = 0.5
CocoaMessage(0,GadgetID(0),"scaleUnitSquareToSize:@",@size)
Values < 1 to make it smaller.
Re: EditorGadGet
Posted: Mon Jul 28, 2014 4:58 pm
by spacebuddy
Thanks Danilo
Do I need to put
CocoaMessage(0,GadgetID(0),"setNeedsDisplay:",#YES)
to refresh the screen?