Alignment Problem :(

Hi,
I have an empty project apart 3 buttons and a TextArea.

The buttons are LeftAlignment, CenterAlignment, and RightAlignment.
They work as expected with regards to aligning selected text, BUT, if I click on a line which has not been specifically aligned, the button toggle does not update.

Example:
If you compile and run my app, then type 3 separate lines of text, and then CenterAlign the top line - you will notice that the CentreAlign stays highlighted, even if you select line 2 which is LeftAligned?

Could someone please look at the code in my project file, and let me know what I am doing wrong?
Link to file

Thank you all in advance.

Just add:

  LeftAlignButton.textColor = &c000000
  RightAlignButton.textColor = &c00000
  CenterAlignButton.textColor = &c000000

At the top of your selChange event.

The problem was that you were never changing the button text back to black!

Note that this still as a “bug” in that unless you explicitly set a line to align left, the button color won’t change – I believe that’s because the textArea doesn’t return true for align left when it’s aligned left by default. A fix might be setting all the text in the textArea to align left initially.

Thanks Marc,
Your 3 lines of code worked :slight_smile:

Now if only I could get the buttons caption to be italicised.
You can make a buttons caption bold or underlined, but not italicised.

Grrrrrrrrrrrrrrrr

[quote=84432:@Richard Summers]Thanks Marc,
Your 3 lines of code worked :slight_smile:

So, you are saying that due to a bug, I will need to put the following code in the TextField’s Open Event:

TextArea.SelAlignment=TextArea.AlignLeft

Richard this isn’t a bad practice for some of your controls. Ie. I usually have an open event for my Textfields to add custom stuff at runtime. If you are compiling for OS X give this a try in your textfield open event.

  #IF TargetMacOS Then
    Declare Sub setBezelStyle Lib "Cocoa" Selector "setBezelStyle:" (handle As Integer, value As Integer)
    setBezelStyle(Me.Handle, 1)
  #Endif

Mike,
My app is OS X mavericks only.

What does that declare actually do?

Makes your Textfield have that nice round rectangle appearance that we all have come to love in OS X :slight_smile:

Just realised - I already have that for my other TextFields.

The reason I could see no difference, is that my TextField extends the entire width of my window :slight_smile: