Accueil → WINDEV 22 → [WB23] - Moving a control and knowing its position
[WB23] - Moving a control and knowing its position
Débuté par JP, 06 juin 2018 17:00 - 3 réponses
Posté le 06 juin 2018 - 17:00
Hi All

WB23 Dynamic site.

I have a template control which contains an image and a button. I have page on which i have an instance of this template control. The control can be moved by the background. The user can therefore click the control and move it around the web page. This all works fine.

The problem I have is knowing where the control has been moved to. I want to record the control's X and Y position so that I can restore the control to that position in future. However, I cannot see where I can know this information. I know that I can access the control's ..X ..Y properties but they return the default 0,0 position and not the new position the control has been moved to.

Any suggestions?
Posté le 06 juin 2018 - 19:43

did you try in browser code? The server side would have no way of knowing the new positions... You can then send them to the server using ajaxexecute (by example)

Best regards
Posté le 11 juin 2018 - 13:35
Hi Fabrice

I was looking at this but there is an additional problem I have. A user can move a control around and I can use your suggestion to allow the user to send to the server the location of the moved control. However, my desire is to also allow a user to clone (i.e. duplicate) a control and move that around too. But now I would need a method to enumerate the controls on the page in order to send all their lcoations to the server. But one cannot use EnumControl() in browser code ... so is there a way, in browser code, to enumerate the various controls on a page and send their locations to the server?

Many thanks
Posté le 11 juin 2018 - 17:38

I do not htink that is possible, at least not that way, BUT, maybe, you can do something like that:
- the user select a control by clicking on it
- therefore in the browser code for that control, you can have a code that store the name of the control (myself..name) in an edit field or variable
- when the user moves the control, you can use that name to find the position and sending it immediately to the server

So no enumeration and sending everything at once, but one at a time, WHEN MOVED...

Best regards