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.
It’s a custom one (I think it is a subclass of Canvas - or maybe of RectControl directly).
Have you tried the MouseDown event?
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 )
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.
Bonus is it will be cross platform
Thanks for sharing your example. Pretty cool stuff I will take into consideration.
Column( n).WidthActual is what I was looking for…
I knew there is something existing but couldn’t recap.
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.
While at one time that needed to know the row height for sure , that is no longer the case. Now you can use ListBox.RowHeight,