Hello, I had a *quick* look into your code (https://ooktech-tw.gitlab.io/plugins/caretposition) and I wanted to share some thoughts.
1 - the fact that the position is always one step late is *MAYBE* because your event handler for the "input" event of the active widget is called before the regular input event handler (for example, before a textarea has received this event and inserted a caracter after the user has typed something), so for your event handler, the caret position is the position BEFORE the input of the user is really processed. But I am not sure. 2 - if you want to detect/react to arrows and other keys, the "input" event is not the good one to track. I chose to do most of my processing on the "keyup" event (in part, also, to address problem 1) above). 3 - it is a very nice idea to store the result of the caret position computation into a Tiddler. In fact, it might be the only way to have a wikimacro or widget be able to use this information to display a popup without having to rely on some more javascript. 4 - currently, I have the impression that the carret position is stored globally in two attributes of $tw ? It is a work in progress I guess, end ultimately you would like to store theses values in a tiddler ? You approach (the CaretPosition in tidddler and the EditorMagic you aim at) is indeed way more generic than my approach which targeted only special pattern in a textarea. My approach would not work on a title editor field, or on a tag editor field. I am not sure that a global behavior is in fact needed. Have you a list of all text fields or areatext where popup information under the caret would be needed ? In the meantime, I will try make a more compact module/widget/plugins with only one function : put the current carret position in a tiddler, while reusing what I did, but with no processing at all from the text under the carret. I let you know if I make any progress. Snowgoon Le vendredi 17 avril 2020 22:20:24 UTC+2, Jed Carty a écrit : > > Mat, > > You are much better with css than I am. I had to add on the scroll > position to the position value but it works. The only problem I have found > is that when you are typing in the search box and then you scroll the story > river with the popup active it will scroll with the river, but once you > continue typing it goes back to the correct position. > > There is still the refresh problem where the position is always one step > behind where it should be, that should be able to be handled with the > widget somehow, I need to look into it. I will push the changes in a moment. > > On Thursday, March 5, 2020 at 9:02:02 PM UTC+1, Mat wrote: >> >> Dear all, for EditorMagic <http://editormagic.tiddlyspot.com/> I am >> really hoping to show the popup at cursor position. Fellow Snowgoon uses >> this code in his comptext plugin in TW: >> >> >> https://github.com/snowgoon88/TW5-extendedit/blob/master/plugin/files/cursor-position.js >> >> I don't understand js. How would I use this to position a div? Is it >> possible? Is there some kind of command? >> >> What I want to do is to control the position of a popup (a div) to be >> just below the cursor. I assume the most critical bit for this is to >> identify the x,y values for the cursor. >> >> Thank you. >> >> <:-) >> >> >> -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/e47dd05d-e521-4dca-acea-012369cf73be%40googlegroups.com.
