Creating a bulleted list in TextArea

Hi, guys,

I wonder if it is possible to create a toggle button next to the TextArea field that would do the following:

  1. if the button is pressed, each time the user presses Enter, the new line starts with period and a space
  2. if a part of the text is selected and the button is pressed, it converts the selected text into a bulleted list

Thank you.

Val

On OSX you can use the Font Inspector Bar

TextArea.Open

  #if targetCocoa
    declare function documentView lib "Cocoa" selector "documentView" _
    (obj_id as Integer) as Ptr
    
    declare sub setUsesInspectorBar lib "Cocoa" selector "setUsesInspectorBar:" _
    (obj_id as Ptr, value as Boolean)
    
    setUsesInspectorBar(ptr(documentView(me.Handle)), true)
  #endif

Axel, do you mean that the declare you posted above causes that entire toolbar to display?

Thanks.

[quote=131614:@Richard Summers]Axel, do you mean that the declare you posted above causes that entire toolbar to display?

Thanks.[/quote]
Correct, the whole thing displays.

Wow, never knew that!
Thanks guys.

On a similar note - If you had a text area, and used that toolbar to create underlined and emboldened text, and then saved it out as a rtf file - what would happen when you tried to load it back in to a txt area? Would the formatting be retained, or are extra steps required?

Yes

No, I was not aware of that. Fantastic bit of code which does a massive amount of work.

The only thing i note on my machine is the toolbar everything looks small like I zoomed out 2x.

OSX Yos MB Air 13inch - Xojo 2014 2.1

it is the same font inspector as in TextEdit. it has no zoom

No what I mean is the controls are only 15px high. The text in the combo box is only 7px high

I agree, everything on the toolbar looks like it was created by ants :slight_smile:

it looks not the same as in TextEdit?

Yes, it looks the same - too small for the window :slight_smile:

I have no toolbar in textedit.

Yes, or for ants. Come on Richard i’m not sure they code.

I also had a declare which displayed the ruler, but I can no longer seem to find it :frowning:

Oh, I have that code, @Axel Schneider posted it on Xippets some time ago, its here:

make 2 Methods

Function myTextView(t as TextArea) As Ptr
  #if TargetCocoa then
    declare function documentView lib "Cocoa" selector "documentView" _
    (obj_id as Integer) as Ptr
    return documentView(t.Handle)
  #endif
End Function

Sub ShowRuler(t as TextArea, value as Boolean)
  #if targetCocoa
    declare sub setRulerVisible lib "Cocoa" selector "setRulerVisible:" _
    (obj_id as Ptr, value as Boolean)
    setRulerVisible myTextView(t), value
  #endif
End Sub

call it (Button)



  If me.Caption = "Show Ruler" then
    me.Caption = "Hide Ruler"
    ShowRuler TextArea1, true
  else
    me.Caption = "Show Ruler" 
    ShowRuler TextArea1, False
  End If

Thanks Mike.
I believe the calling of the method should have the parameters enclosed in brackets?

Please tell me there is something equivalent for Windows …?!

It will work without brackets - they are optional here.