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
Use native HTML5 Drag'n'Drop for text. #1599
Conversation
Fixed IE issues (reverted captureMouse logic). |
Selection is correct after undo if text was moved below (or right). It's wrong if you move text to the left or to the top. |
This is absolutely awesome! For 'wrong selection on undo' issues, i am going to change it to keep and restore actual selection instead of reconstructing from change ranges. |
What is your version of Opera? 12.14 (win7) works fine. Can you check CodeMirror? It uses similar workaround (in fact, I stole it :) ) |
I was testing on 12.14 too. Seems like it happens only when splitview is active. |
It seems image must be rendered on screen. Is it ok if image always present (in Opera) at screen with such styles? element.style {
position: fixed;
height: 1px;
width: 1px;
top: 0px;
left: 0px;
opacity: 0;
visibility: hidden;
z-index: 2147483647;
}
|
I think it's ok. |
Opera drag image is fixed. |
@@ -13,6 +16,7 @@ | |||
top: 0; | |||
bottom: 0; | |||
background-color: inherit; | |||
z-index: 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scrollbar elements are a bit wider, than their visible part. This is needed to overlap invisible part of scrollbar, so autoscroll triggers at very edge of scroller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work on mac since scroller will completely cover scrollbar elements. Can we add drag listeners to the container instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm..Changing event target seems working, but I don't like that scrollbars turned into drop zones..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why, in textarea scrollbars are drop zones, in notepad++ both gutter and scrollbars are drop zones, i think it's much better.
} | ||
this.setState("dragWait"); | ||
} else { | ||
this.startDrag(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must not be called on double/triple/quad click. How can we pass click count here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe set clickCount on event in multimousedown listener and add getClickCount to mouseEvent?
Good to know what causes flickering on opera, i agree that fixing it is better left for the future. |
In old version dragging was disabled for multiselect, but here it only drags text from the last selection. Also on IE when ctrl+clicking on selected text there is a quick flash of native selection. |
also it shouldn't loose it's scroll position if text is dragged over it to another editor |
Phhhhhh...Many bad words to webkit developers... Chrome dispatches fake mousemove events sometimes.. This breaks drag ability. I will try to use the same workaround: https://github.com/ajaxorg/ace/pull/1599/files#L7R340 |
Ok. if we just pass by, editor should stay still. If we stop moving and delay for 250ms over inactive editor - editor come to live. Do you like this, @nightwing ? |
It could be done differently: set delay for autoscrolling and do not restore previous scroll position on dragleave. I like this more. |
Was going to make the same comment:) Yes delay for autoscrolling is better. |
Add overlay (css ::before generated content) while dragging to prevent IE to trigger `drop` event while autoscrolling
Ok, now all issues are fixed (I would like to separate multiselect issue from this). |
Ok, looks good to me. |
var dragOperation; | ||
var autoScrollStartTime; | ||
var cursorMovedTime; | ||
var cursorPointOnCaretMoved; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for bad variables naming, I have no idea how to name them better.
Unfortunately, new bug. On dblclick (quadclick, and every even click), Firefox does not capture mouse outside window. So, when you doubleclick an editor to select by words and move your mouse outside a window and release mouse there - editor will not receive mouseup event. |
FF bug isn't caused by this pull request it is present on master too. |
Is associated Firefox bug filed on bugzilla? Can't find. If no, I'll file it. |
Alright, I tested this on OSX with Chrome, Firefox, Safari. Seems to work! One thing that is different compared to master is that it now shows an arrow cursor instead of a "move" cursor. Combined with #1609 that doesn't make it very intuitive to use, as you get no feedback that you're dragging text: http://screencast.com/t/Aqx8fXhC. (Note that #1609 is something that also existed in master, it's not necessary to address that as part of this PR.) |
@@ -23,6 +27,25 @@ | |||
cursor: text; | |||
} | |||
|
|||
.ace_dragging, .ace_dragging * { | |||
cursor: default !important; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This used to be the "move" cursor, would it be okay to put it back? (seems to work as desired if it's "move")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still, "move" cursor looks wrong and does not match OS system Drag'n'Drop behavior (as far as I know).
I would like to use "default" cursor...
@lennartcl let's merge this since main part of changes are good, and we need to tweak cursor anyway e.g see #303. |
@nightwing @danyaPostfactum Alright, merging as is. Thanks for your contribution @danyaPostfactum! |
Use native HTML5 Drag'n'Drop for text.
Just played with setDragImage: https://rawgithub.com/danyaPostfactum/ace/dragimage/kitchen-sink.html |
Anybody knows how to disable drag image scaling in Firefox? It scales drag image with height > screen height / 2 (it seems) |
This is really nice!
And same for width, but It seems to be impossible to change this behavior. |
We could enable dnd in Safari 5 (Windows) by covering editor with blank textarea. |
I don't think it is worth the effort, almost no one uses safari for windows, and it is not updated anymore. |
Why this branch was not merged? It gives much better feeback while dragging the selected text than current solution. Or is dragging broken? |
Sorry, I donno how to rebase branch, so this is the new version of #1431 .
All issues I wanted are fixed.
This needs test and review.
Issues I would like to fix but need help:
Issues we can not resolve:
Issues I do not know reason of:
Issues I don't like or not sure:
Also, in Firefox, dragenter event fires twice, so dragleave event does not get caret back. Can anybody reproduce?
Great news! All bugs I (or someone else) found in IE and reported to MS are marked as Won't Fix )))
They say those are "by design", "not reproducible" etc :)