I’m trying to convert an older plugin I could make use of to API 2.0. I have done a lot of the work so far, and it is helping me to understand this new API. I come from a VB background so there is a learning curve, but I like learning new things.
I don’t use API 2.0 as it’s too risky to update my existing apps, however it seems that Xojo decided to make the .parent property an object (instead of rectControl), so you need to check if it’s a rectControl or a window, before trying to read it’s top position.
I would recommend that you consider grabbing the mouseLocation in the mouseDown event and stuffing it into a property of the listbox, so that on the double click event you already have a mouse location that’s already been localized to the listbox.
Used to get and set the control’s parent control or window.
If the control is on the window, the Parent will be the Window. If the control is on the container, the Parent will be the container. If the control is completed enclosed by another control, the Parent will be that DesktopUIControl.
If you do not want the enclosing control to be the parent, set the Parent property of that control to Nil to make it the Window.
Just add "DesktopContainer(). Nice and simple, thanks.
Again, I come from a VB background so a lot of what was in RealBasic made sense to me. But I have gotten lost in the weeds a few times with all the changes to API 2.0. I am hopeful that I will find more simple examples like what you have provide here, as more questions arise.
“Descriptive discussions” - Maybe I should have been clearer. The “discussions” I was referring to would be the text accompanying the samples and example code in the documentation.
My “mileage” in the Documentation has varied. But let’s be fair, that has been true of any language I have used.
I guess my issue - IF I was going to claim to have one - would be a desire to have the documentation for API 2.0 include examples or some links to “this not that” examples for people dealing with all the changes.
For example: I can find plenty of interesting things in the docs about what DesktopContainer does, with several examples. But I did not know I needed to make use of DesktopContainer in this instance, without asking for help. When I search for [xojo api 2.0 “DesktopContainer(me.parent)”] in Google (Not the end all/be all search engine, but it works well enough for this example.) I get nothing. When I search for [xojo api 2.0 “me.parent”] I get interesting results but none show an example like the sample code in my original post with DesktopContainer inserted into it, like the API 2.0 solution.
If there was an API 2.0 doc for “Determining which cell was double-clicked” with the modified example it would be easy to compare, see where I went wrong and encourage me to learn more about DesktopContainer.
That document may exist one day. Until it and probably hundreds, if not thousands like it, exist questions like mine, at the start of this thread, will continue.
I am grateful that this forum exists so we have someplace where we can fill-in-the-gap.
In terms of knowing which cell was clicked, AFAIK there is no difference between API 1 and API2 except the names of some of the event handlers have changed. But not so much that you wouldn’t guess which is which.
The technique hasn’t changed either. Just follow what @Sam_Rowlands said upthread: in MouseDown memorise the X and Y and then use them with RowFromXY and ColumnFromXY in the DoublePressed event handler.