top of page

Code to go, NSTextView with Syntax highlight and scroll bars (TMS mCL), Part 1

Code to go no.1 (and our first), How to add NSTextView with scrollbars using mCL? Although TMS Software added this feature today (I didn't test it yet), it is good to know how you can manipulate the encapsulated native NSTextView, so lets start...

Instead of adding TTMSFMXNativeNSTextView directly to our main TForm, we are going to declare it as private TForm variable, don't forget to add FMX.TMSNativeNSTextView to the uses clause:

Next, lets drop a TTMSFMXNativeNSScrollView on our TForm, we are going to allocate an instance of TTMSFMXNativeNSTextView and add it as a child to the TTMSFMXNativeNSScrollView (I am going to name it NSScrollViewForEditor) (By the way, the reference to all of this can be found here: Putting an NSTextView Object in an NSScrollView):

If you are wondering about __NSMakeSize function, it is my own translation to the original Objective C function (in previous versions of Delphi I had runtime errors when I referenced NSMakeSize function that comes with Delphi, which is an external reference in Foundation, I didn't check it back again with 10.1 to see if it is working, however you are free to experiment with it):

For the above to work however (and for future tutorials), we need to add the needed Cocoa framework and the supporting APIs to the uses clause:

Thats it for this "Code to go", code can be downloaded here, next I will demonstrate how to add simple Syntax highlighting. Enjoy coding!

Recent Posts

Archive

Search By Tags

No tags yet.
bottom of page