How to disable the focus ring on a ListIconGadget?
Posted: Thu Jun 25, 2015 4:38 pm
How can i remove the blue focus ring on a ListIconGadget an OS X?
Is there a Cocoa Message for this?
Is there a Cocoa Message for this?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
CocoaMessage(0, GadgetID(ListIconID), "setSelectionHighlightStyle:", -1)
Sorry, I know quite well what a focus ring is. But the situation is not so clear as you might think because it's also possible to draw a focus ring around a single cell (not just selecting a complete row by changing the background to a different color as PureBasic does by default). And that's what I do in some of my programs:thinkitsimple wrote:This is not what i mean. Your example disables the selection of the listicons rows. i want to disable the blue ring around the whole listicon gadget when its getting the focus. this is called the focusring.
Code: Select all
Enumeration NSFocusRingType
#NSFocusRingTypeDefault = 0
#NSFocusRingTypeNone
#NSFocusRingTypeExterior
EndEnumeration
If OSVersion() > #PB_OS_MacOSX_10_8
MessageRequester("Info", "Sorry, this solution works only up to Mountain Lion!")
End
EndIf
OpenWindow(0, 200, 100, 440, 130, "ListIcon Example")
ListIconGadget(0, 10, 10, 420, 80, "Name", 110)
AddGadgetColumn(0, 1, "Address", 302)
AddGadgetItem(0, -1, "Harry Rannit" + #LF$ + "12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit" + #LF$ + "130 PureBasic Road, BigTown, CodeCity")
AddGadgetItem(0, -1, "Didi Foundit" + #LF$ + "321 Logo Drive, Mouse House, Downtown")
ButtonGadget(1, 110, 100, 200, 25, "Disable ListIcon's focus ring")
SetActiveGadget(0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 1 And EventType() = #PB_EventType_LeftClick
FocusRingType = CocoaMessage(0, GadgetID(0), "focusRingType") ! 1
CocoaMessage(0, GadgetID(0), "setFocusRingType:", FocusRingType)
If FocusRingType = #NSFocusRingTypeNone
SetGadgetText(1, "Enable ListIcon's focus ring")
Else
SetGadgetText(1, "Disable ListIcon's focus ring")
EndIf
EndIf
EndSelect
ForEver
Code: Select all
OpenWindow(0, 200, 100, 440, 95, "ListIcon Example")
ListIconGadget(0, 10, 10, 420, 75, "Name", 110, #PB_ListIcon_GridLines)
AddGadgetColumn(0, 1, "Address", 302)
AddGadgetItem(0, -1, "Harry Rannit" + #LF$ + "12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit" + #LF$ + "130 PureBasic Road, BigTown, CodeCity")
AddGadgetItem(0, -1, "Didi Foundit" + #LF$ + "321 Logo Drive, Mouse House, Downtown")
CocoaMessage(0, GadgetID(0), "setBackgroundColor:", CocoaMessage(0, 0,
"NSColor clearColor"))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow