[quote=250853:@Will Shank]In CustomListBox.bbDropList.Action the coordinates you supply only accidentally appear to work. MouseX is the cursor position relative to the Window, and Self.Left is the position of the CustomListBox on the Window. These happen to line up with the default placement of the window, but not in general.
Forget the mouse position, what you want is the top left corner of bbDropList in screen coordinates.
The top/left of bbDropList is it’s position in CustomListbox. The top/left of CustomListbox is it’s position in the Window, and the Windows top/left is it’s position on screen. From this place in code, bbDropList.Action, you refer to each of those with Me, Self, and Self.Window, respectively.
With the following bbDropList.Action code the Popup arrow is always touching the top/left corner. Use these screen coordinates to test which side to show on and x+Me.Width is the right side and y+Me.Height/2 is halfway down.
[code]Sub Action()
dim w As New winListBox
dim x, y As integer
x = Me.Left + Self.Left + Self.Window.Left
y = Me.Top + Self.Top + Self.Window.Top
w.displayPopoverAt(x, y, 1)
End Sub[/code]
Note, this sum will stop working if the CustomListbox is nested inside other ContainerControls. You’d need to loop up the parents or something.[/quote]
Thank Will but it seems that the issue is still there .
So to explain.
On the top listbox when you press the blue button the popover goes outside the screen, down listbox works properly, if you enlarge the window to the whole screen it readjusts properly
i did put some code in the button according to your recommendations and i added some lines so that it shifts on left or right according to the position of the listbox on the screen.
[code]dim w As New winListBox
dim x, y As Integer
x = me.Left + self.Left + self.Window.Left
y = me.Top + Self.Top + Self.Window.Top
dim location As Integer
If Screen(0).Width /2 < x Then
location = 1
Else
location = 3
End If[/code]
i`ll have to tune it more.
As said the down right one works always perfectly, but the upper left one even with our code changes still goes outside the screen area.
As for the CustomListBox that will be placed on a window so normally that should be the final control on the window, i hope it will not affect anything , same as the current setup.
I have to see this issue,
Now , i know that i have top and bottom options on the popup but i want just the left/right options and the popup to shift up/down according to the location, so that nudge should mode as the one in the right down, but the problem is that it is not moving and i don`t know why, i guess it is something related to the offset i have to see where exactly.
And the idea will be so that it does not cover the main one for reference so it should be something like that :
[code]dim w As New winListBox
dim x, y As Integer
x = me.Left + self.Left + self.Window.Left
y = me.Top + Self.Top + Self.Window.Top
dim location As Integer
If Screen(0).Width /2 < x Then
location = 1
w.displayPopoverAt(x - self.Width + me.Width ,y + me.Height/2,location)
Else
location = 3
w.displayPopoverAt(x + me.Width,y + me.Height/2,location)
End If[/code]
The issue on the top one still remains that it goes outside the visible screen area .
Thanks again.