I am wondering if it’s possible to modify the listbox or the “textfield cells” with declares or is it a custom one ? I am asking because I am looking
for a solution to get the frame (w,h,top,left) of the clicked cell to calculate my custom popover or even a future implementation of a popover.
I was going to access the cell object in the “clicked” event of the listbox from the ActiveCell.Handle but that doesn’t seem to work as .left and .top
is always 0.
How can I figure out?
I am currently using System.MouseX/Y but it’s not accurate if you want to have a popover adjusting to the middle left/right/top/bottom.
made a workaround using/tracking CellClick - xy coordinates, saving them to self.cellRelX/Y and the passing these over to the popover which calculates the final left / top for the popup window.
<calling from Listbox DoubleClick>
dim x as integer = System.MouseX
dim y as integer = System.MouseY
...
...
// passing ListBox reference to the EditWindow. Need it either way.
EditWindow.MLB = self // there we have cellRelX/Y
EditWindow.ShowRelativeToRect( x, y )
<EditWindow.ShowRelativeToRect>
dim w as new NSWindow( self )
w.AnimationBehavior = NSWindow.NSWindowAnimationBehavior.NSWindowAnimationBehaviorDocumentWindow
dim winMidY as integer = w.FrameHeight/2
w = nil
ArrowCanvas.Top = ( winMidY - (ArrowCanvas.Height/2) )
dim widths() as integer = self.MLB.ColumnWidths.SplitToInteger( ", " )
dim mid as integer = (self.MLB.RowHeight/2)
dim offset as integer = mid - self.MLB.cellRelY
self.Top = y - (winMidY + offset)
self.Left = x + ( widths( self.col ) - self.MLB.cellRelX )
The only thing I dislike in the code is they way I get the ColumnWidth from the string. Does anyone know how to get the current columnWidth of the clicked row/column ?
I knocked up a Listbox subclass which raises an event CellClickWithSize(row as integer,column as integer,x as integer,y as integer,cellSize as Realbasic.Rect) when the cell is clicked in. Note you must set the DefaultRowHeight property of the ListBoxPlus subclass for it to work.
For what it’s worth, you can probably make a property for storing the actual row height on your subclass and then just set it from within the CellBackgroundPaint event If it’s zero using g.Height.