B4J Question Detect the end of a window being resized

DarkMann

Member
Licensed User
Longtime User
I'm drawing a complicated layout on the screen, adding lots of panes, labels, etc. The window is resizeable and I have the redraw code firing when the resize event fires for the window. This works, but because it all takes time to redraw, it is very "flickery".

The redraw also calls down some data that it needs from a remote database and this means the data is requested multiple times per second while the redraws are fired repeatedly.

Is there a way to detect the end of a window resize dragging operation? That way I could fire the redraw once when the mouse is released.

David
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The redraw also calls down some data that it needs from a remote database and this means the data is requested multiple times per second while the redraws are fired repeatedly.
This sounds like a bad idea.


1. Add a global int variable named ResizeIndex.
2.
B4X:
Sub MainForm_Resize (Width As Double, Height As Double)
   ResizeIndex = ResizeIndex + 1
   Dim MyIndex As Int = ResizeIndex
   Sleep(1000) 'change duration as needed
   If MyIndex = ResizeIndex Then
       Log("resize complete!")
   End If
End Sub
 
Upvote 0

DarkMann

Member
Licensed User
Longtime User

Thanks Erel, that will work fine for what I need for now. I sort of missed the obvious solution I think.

I agree about the remote call not being a good idea, but it is only across the local network to a database and I don't want to store any data on the client as it makes keeping it all safely in sync easier.

David
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
other idea, uncouple the ui root element object from the form at any resize, and after a delay of half second without resize add it back to the form.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…