Cursor position in WebGadget
Cursor position in WebGadget
Hello to all,
maybe the question is a bit strange. Does anyone know if you can place, with a function, the mouse cursor to a certain point (x, y) of a WebGadget? Obviously the WebGadget is in edit mode.
Case Study The truth is this: when I save the contents of the WebGadget, the cursor is always at the beginning and not where it was before me to save. (I spit as I only raised the issue) ...
maybe the question is a bit strange. Does anyone know if you can place, with a function, the mouse cursor to a certain point (x, y) of a WebGadget? Obviously the WebGadget is in edit mode.
Case Study The truth is this: when I save the contents of the WebGadget, the cursor is always at the beginning and not where it was before me to save. (I spit as I only raised the issue) ...
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Cursor position in WebGadget
If your app is Windows only, then the API SetCursorPos_(x,y) can be used. It's actually a screen position, so to set the position of x15, y15 you would do something like this:
For greater precision, PB now has mode flags for the likes of WindowX().
Code: Select all
iX = WindowX(#MyWin) + GadgetX(#MyWebGt) + 15
iY = WindowY(#MyWin) + GadgetY(#MyWebGt) + 15
SetCursorPos_(iX,iY)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Cursor position in WebGadget
Thanks for the reply IdeasVacuum. I had already tried with this solution, but unfortunately it does not work. When I write in a WebGadget the cursor is located at a certain position. When I save the content I would like the cursor stays where it was before you save, instead always moves to the beginning of the WebGadget. This is the problem.
Re: Cursor position in WebGadget
Please try the following example: when clicking onto the button, the cursor is positioned in the middle of the WebGadget using SetCursorPosition_() as proposed by IdeasVacuum.
Code: Select all
If OpenWindow(0, 0, 0, 600, 350, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 10, 10, 580, 300, "http://www.purebasic.com")
ButtonGadget(1, 190, 320, 200, 20, "Position cursor in WebGadget's middle")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 1
If EventType() = #PB_EventType_LeftClick
SetCursorPos_(WindowX(0, #PB_Window_InnerCoordinate) + GadgetX(0) + GadgetWidth(0) / 2, WindowY(0, #PB_Window_InnerCoordinate) + GadgetY(0) + GadgetHeight(0) / 2)
EndIf
EndIf
EndSelect
ForEver
EndIf
Re: Cursor position in WebGadget
Thanks to you too Shardik. I apologize because I may have exposed the problem of evil. In fact I'm using the WebGadget as WYSIWYG editor, then the cursor is blinking where I'm inserting a character and moves accordingly. If I had added 10 characters, the cursor would be just after the last character entered. When I save the content I want the cursor to remain where it is, rather than to the beginning of WebGadget (the character 0.0 for instance).
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Cursor position in WebGadget
ah, you want to know where the caret is in the text, and keep it there. I wondered what you meant by 'edit mode', I have no experience of doing that with the webgadget.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Cursor position in WebGadget
Yes...
Sorry...

Re: Cursor position in WebGadget
Hello RASHAD. The code is too long, but I'll explain briefly.
1 - I write within a WebGadget;
2 - Save the contents of the WebGadget with GetGadgetItemText (gadgets, #Pb_Web_Html)
3 - Reloading WebGadget in the newly saved page with SetGadgetText (...).
At this point, having reloaded the page, the Caret is positioned at the beginning of WebGadget, but I have the need to place it at the end of the text that I had just entered. I hope I explained well. I'm sorry.
1 - I write within a WebGadget;
2 - Save the contents of the WebGadget with GetGadgetItemText (gadgets, #Pb_Web_Html)
3 - Reloading WebGadget in the newly saved page with SetGadgetText (...).
At this point, having reloaded the page, the Caret is positioned at the beginning of WebGadget, but I have the need to place it at the end of the text that I had just entered. I hope I explained well. I'm sorry.
Re: Cursor position in WebGadget
OK
Try and give us the results
Try and give us the results
Code: Select all
Global p.POINT
;Now before saving
GetCaretPos_(p.POINT)
.
.
.
.;After loading the page
SetCaretPos_(p\x,p\y)
Egypt my love
Re: Cursor position in WebGadget
RASHAD Hello, thank you very much for your trouble.
Unfortunately, all I'm trying but the cursor does not want to know. When I save and reload the page to give him any information he, damn, you are always placed at the beginning of the page. I do not give up, if I find the solution I will put the current. Thank you all for the help. Hello 

