Does anyone know how to get the NSScrollView handle internal to a ScintillaGadget?
I'm not sure what GadgetID() points to, for a ScintillaGadget.
[Solved] NSScrollView from ScintillaGadget
[Solved] NSScrollView from ScintillaGadget
Last edited by kenmo on Fri Nov 20, 2015 11:22 pm, edited 1 time in total.
Re: NSScrollView from ScintillaGadget
To clarify, my end goal is to change the white background color of OS X ScintillaGadget (beyond the SCI_SCROLLWIDTH).
Example and experimenting code...
Example and experimenting code...
Code: Select all
EnableExplicit
Procedure.i NSColor(RGB.i)
Protected.CGFloat r, g, b, a
r = Red(RGB) / 255.0
g = Green(RGB) / 255.0
b = Blue(RGB) / 255.0
a = 1.0
ProcedureReturn (CocoaMessage(0, 0, "NSColor colorWithDeviceRed:@", @r, "green:@", @g, "blue:@", @b, "alpha:@", @a))
EndProcedure
Procedure.i Cocoa_SetBackgroundColor(Object.i, RGB.i)
ProcedureReturn (CocoaMessage(0, Object, "setBackgroundColor:", NSColor(RGB)))
EndProcedure
Procedure.s Cocoa_ClassName(Object.i)
Protected Result.s
CocoaMessage(@Object, Object, "className")
CocoaMessage(@Object, Object, "UTF8String")
Result = PeekS(Object, -1, #PB_UTF8)
ProcedureReturn (Result)
EndProcedure
Procedure.i Cocoa_Superclass(Object.i)
ProcedureReturn (CocoaMessage(0, Object, "superclass"))
EndProcedure
Procedure.i Cocoa_Superview(Object.i)
ProcedureReturn (CocoaMessage(0, Object, "superview"))
EndProcedure
Procedure Cocoa_DebugClasses(Object.i)
Debug "Superclasses:"
While (Object)
Debug Cocoa_ClassName(Object)
Object = Cocoa_Superclass(Object)
Wend
EndProcedure
Procedure Cocoa_DebugViews(Object.i)
Debug "Superviews:"
While (Object)
Debug Cocoa_ClassName(Object)
Object = Cocoa_Superview(Object)
Wend
EndProcedure
DisableExplicit
OpenWindow(0, 0, 0, 200, 200, "Test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
InitScintilla()
ScintillaGadget(0, 0, 0, 200, 100, #Null)
ScintillaSendMessage(0, #SCI_SETSCROLLWIDTH, 100, 0)
ScintillaSendMessage(0, #SCI_STYLESETBACK, #STYLE_DEFAULT, RGB(192, 255, 255))
ScrollAreaGadget(1, 0, 100, 200, 100, 100, 50)
CloseGadgetList()
Cocoa_SetBackgroundColor(GadgetID(1), RGB(192, 255, 255))
ID = GadgetID(0) ; PBScintillaView
ID = Cocoa_Superview(ID)
ID = Cocoa_Superview(ID)
Cocoa_SetBackgroundColor(ID, RGB(255, 255, 192))
CocoaMessage(0, ID, "setDrawsBackground:", #YES)
Cocoa_DebugClasses(ID)
Debug ""
Cocoa_DebugViews(ID)
Debug ""
Repeat
Event = WaitWindowEvent()
Until (Event = #PB_Event_CloseWindow) Or (Event = #PB_Event_Menu)
Re: NSScrollView from ScintillaGadget
Something like this ?
Code: Select all
ID = GadgetID(0) ; PBScintillaView
ScrollView = CocoaMessage(0, ID, "scrollView")
Cocoa_SetBackgroundColor(ScrollView, RGB(255, 255, 192))
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: NSScrollView from ScintillaGadget
Wow. THANK YOU! So simple, when you know the right Cocoa method to use.
I was experimenting based off this bit of the Scintilla source:
This solves my "big white Scintilla area" problem on Mac (which the PB IDE used to have)
so I no longer have to set a super wide Scintilla scrollWidth (which the IDE currently does)
which essentially solves this beyond-ScintillaGadget cursor bug (which the IDE currently has).
I was experimenting based off this bit of the Scintilla source:
Code: Select all
/**
* Helper function to get the scrolling view.
*/
NSScrollView* ScintillaCocoa::ScrollContainer() {
NSView* container = static_cast<NSView*>(wMain.GetID());
return static_cast<NSScrollView*>([[container superview] superview]);
}
so I no longer have to set a super wide Scintilla scrollWidth (which the IDE currently does)
which essentially solves this beyond-ScintillaGadget cursor bug (which the IDE currently has).
Re: NSScrollView from ScintillaGadget
I also looked at the Scintilla source to come up with this but maybe I looked in a different location.kenmo wrote:Wow. THANK YOU! So simple, when you know the right Cocoa method to use.
Anyway, I'm glad it works for you
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)