EditorGadGet

Mac OSX specific forum
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

EditorGadGet

Post by spacebuddy »

is there any way to move the cursor to a word in the EditorGadget?? :shock:
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: EditorGadGet

Post 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 ;)
WilliamL
Addict
Addict
Posts: 1259
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: EditorGadGet

Post by WilliamL »

MacBook Pro-M1 (2021), Tahoe 26.2, PB 6.30b6
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

Re: EditorGadGet

Post by spacebuddy »

yes, that works :D
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

Re: EditorGadGet

Post 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 :shock:

I think something wrong in my code :mrgreen:
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: EditorGadGet

Post by Danilo »

Is 'gadget' the GadgetID()? What about defining 'exists' as .l or .i?
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

Re: EditorGadGet

Post by spacebuddy »

Danilo,

Yes, gadget is the ID of the EditorGadget.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: EditorGadGet

Post by wilbert »

You need textStorage. Once you have the textStorage object, you can do a lot with that. 8)

Code: Select all

  textStorage = CocoaMessage(0, GadgetID(0), "textStorage")
  Debug CocoaMessage(0, textStorage, "containsAttachments")
Windows (x64)
Raspberry Pi OS (Arm64)
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

Re: EditorGadGet

Post by spacebuddy »

Thanks Wilbert :D
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

Re: EditorGadGet

Post 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 :oops:

ScrollView = CocoaMessage(0,GadgetID(0),"ScrollView")
CocoaMessage(0, ScrollView, "zoomScale:@",2)
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: EditorGadGet

Post 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.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: EditorGadGet

Post 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)
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

Re: EditorGadGet

Post by spacebuddy »

Thanks Guys :D

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?
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: EditorGadGet

Post 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.
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

Re: EditorGadGet

Post by spacebuddy »

Thanks Danilo :D

Do I need to put
CocoaMessage(0,GadgetID(0),"setNeedsDisplay:",#YES)
to refresh the screen?
Post Reply