Page 1 of 1

Text Selection/Highlight Color for Editor or String Gadget

Posted: Sat Feb 25, 2017 1:13 pm
by coder14
I've found posts for changing the text selection/highlight color for EditorGadget and TextGadget on Windows. Is there any way to do this on MacOS?

Re: Text Selection/Highlight Color for Editor or String Gadg

Posted: Sat Feb 25, 2017 6:30 pm
by WilliamL

Re: Text Selection/Highlight Color for Editor or String Gadg

Posted: Sat Feb 25, 2017 7:14 pm
by Keya
or if you mean just changing which part of the text is selected (using the default highlight/selection color) see the last code snippet here https://purebasic.developpez.com/faq/?p ... ing-Gadget

Re: Text Selection/Highlight Color for Editor or String Gadg

Posted: Sun Feb 26, 2017 3:08 am
by coder14
I'm looking to change the HIGHLIGHT color when text in the editor or string gadget is SELECTED when we PRESS THE LEFT MOUSE BUTTON AND DRAG or when we PRESS THE SHIFT AND ARROW KEYS.

Image

The Windows version done by Sparkie is here:

http://forums.purebasic.com/english/vie ... 6a#p215974

Could this be done in MacOS?

Re: Text Selection/Highlight Color for Editor or String Gadg

Posted: Sun Feb 26, 2017 7:50 pm
by wilbert
Something like this ?

Code: Select all

If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(0, 8, 8, 306, 133)
  
  Attributes = CocoaMessage(0, 0, "NSDictionary dictionaryWithObject:", 
                            CocoaMessage(0, 0, "NSColor orangeColor"),
                            "forKey:$", @"NSBackgroundColor")
  
  CocoaMessage(0, GadgetID(0), "setSelectedTextAttributes:", Attributes)
  
  For a = 0 To 5
    AddGadgetItem(0, a, "Line "+Str(a))
  Next
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: Text Selection/Highlight Color for Editor or String Gadg

Posted: Mon Feb 27, 2017 4:03 am
by coder14
wilbert wrote:Something like this ?

Code: Select all

If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(0, 8, 8, 306, 133)
  
  Attributes = CocoaMessage(0, 0, "NSDictionary dictionaryWithObject:", 
                            CocoaMessage(0, 0, "NSColor orangeColor"),
                            "forKey:$", @"NSBackgroundColor")
  
  CocoaMessage(0, GadgetID(0), "setSelectedTextAttributes:", Attributes)
  
  For a = 0 To 5
    AddGadgetItem(0, a, "Line "+Str(a))
  Next
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
EXACTLY! That did it! :D :D :D

Thank you wilbert. You're my savior.