-
Notifications
You must be signed in to change notification settings - Fork 9
Right click doesn't offer paste at empty prompt #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I managed to paste using long press on android which offered the paste.
…On Thu, 28 Mar 2019 at 18:15, Brian Dickens ***@***.***> wrote:
I added a couple of hooks to strip off formatting when pasting text into
the ReplPad, or when copying text out of it:
39d2660
<39d2660>
That's a welcome improvement! But while trying it out I noticed that right
clicking in an empty prompt doesn't offer the usual text-insertion option
of pasting text. It makes the cursor vanish and offers different options
like viewing source or saving. So not a "quick edit" menu--or whatever you
call it.
But typing text and putting the cursor in the middle of it gets the right
menu.
I think this pertains to the idea that right clicking does some of the
normal click logic first, and then the oncontextmenu event after that.
There's currently a bit of a tapdance to get it to position the cursor in
the right place at all based on clicking in the big empty space...and I'm
sure I'm probably doing that wrong.
So this is probably suggesting a closer look at why the juggling is needed
in the left click case; and if that weren't needed, it might make the
context menu just work. Otherwise it might be necessary to mirror some of
the logic to be focused on the right place in the oncontextmenu event.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#37>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMeQqtAk3y8B6vtwbxXv0SqkF-2JgDzks5vbE_igaJpZM4cPUGB>
.
--
Graham Chiu
|
I have been looking into this, and I'm pretty sure it is related to the comments I posted in #38 The context menu doesn't appear because the div is empty, and so there is no selection range in which to trigger it. If I add Still looking into workarounds ... |
It appears like changing the input <div> to a <textarea> will fix the issue, and then you can get rid of all that messy contenteditable handling. The <textarea> border can be hidden, and it can also be made to grow in size as you type. I have something working locally that appears to do the same job as the <div>. Unless you can think of a specific reason why contenteditable is needed, then I'll start putting my changes into a new branch and you can try it out there. |
I was trying to leave the door open to things like syntax highlighting as you input, or automatically hyperlinking links, or things like that. As far as I know, a textarea can't do any of that, so I was looking to work from a foundation that would allow it. |
Oh, I see. Yea, a textarea won't give you that. I'll keep looking into a contenteditable solution then. |
I have found a working contenteditable solution. Please see PR #40 |
Great! I can now accomplish a paste from a right click! Definitely an improvement over not being able to. :-) It's still a pretty narrow space. Looking at the element layout with the "hover and inspect" tool, it's a small target, and then there's all that padding. I'm wondering if while there's input if there's any way that the input div could somehow be the padding--generating a larger clickable target--yet still aligning the text in the right place? :-/ I threw in the padding because it felt awkward to get too close to the bottom. I'm not sure exactly what all could be done with the space (while running it could show a "I'm running dot-dot-dot" kind of animated icon there?") |
Maybe a larger min-width and min-height on the input div will do the trick? I think the vertical-align will keep the text aligned at the top, even if you add extra space. I'll try it out in the next couple days, if you don't get to it first. |
not working in the test-repl on Chrome |
@gchiu What is the test-repl you are referring to? Also, have you tried clearing your cache and restarting the browser? The REPL will not work right after these changes until you do that. |
Due to some complexities and atrophy of this feature, I thought to look into what it might take to do event forwarding... to forward right clicks or context menu events or whatever. But it seems that programmatic triggering of context menus is simply not a supported scenario in today's browsers. I'm looking into other approaches but just wanted to write down that such forwarding won't work, and what I'd tried:
When right click happens we do not get the click event, just the contextmenu event. I tried changing the coordinates but it didn't matter. Other sources on the internet corroborate that programmatic triggering of context menus on el 8000 ements is not a supported scenario. |
Took the last few days to rip things apart to the point I understood them well enough to throw in some ideas. Now I understand what @BrianOtto was talking about. :-) I decided that Lines 191 to 224 in b732b56
But as pointed out, you can't use minimum width on that. It collapses to zero pixels. But I applied two tricks:
Guess it will just be something to try for a while and see if it works well enough. Better ideas will always be welcome... |
I added a couple of hooks to strip off formatting when pasting text into the ReplPad, or when copying text out of it:
39d2660
That's a welcome improvement! But while trying it out I noticed that right clicking in an empty prompt doesn't offer the usual text-insertion option of pasting text. It makes the cursor vanish and offers different options like viewing source or saving. So not a "quick edit" menu--or whatever you call it.
But typing text and putting the cursor in the middle of it gets the right menu.
I think this pertains to the idea that right clicking does some of the normal click logic first, and then the
oncontextmenu
event after that. There's currently a bit of a tapdance to get it to position the cursor in the right place at all based on clicking in the big empty space...and I'm sure I'm probably doing that wrong.So this is probably suggesting a closer look at why the juggling is needed in the left click case; and if that weren't needed, it might make the context menu just work. Otherwise it might be necessary to mirror some of the logic to be focused on the right place in the
oncontextmenu
event.The text was updated successfully, but these errors were encountered: