Skip to content
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

drag/drop issues #7

Merged
merged 2 commits into from
Oct 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private void showDetails(InputEvent evt, double x, double y) {
* We might run in the sampler application. Then the entry view will not
* be inside a date control.
*/
if (control != null) {
if (control != null && getParent() != null) {
Callback<EntryDetailsParameter, Boolean> callback = control.getEntryDetailsCallback();
EntryDetailsParameter param = new EntryDetailsParameter(evt, control, getEntry(), getParent(), x, y);
callback.call(param);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class DayViewEditController {

private static final Logger LOGGER = LoggingDomain.EDITING;

private boolean dragging;
private DayViewBase dayView;
private DayEntryView dayEntryView;
private Entry<?> entry;
Expand Down Expand Up @@ -80,7 +81,9 @@ private void initDragModeAndHandle(MouseEvent evt) {
}

private void mouseMoved(MouseEvent evt) {
initDragModeAndHandle(evt);
if (!dragging) {
initDragModeAndHandle(evt);
}

if (handle == null) {
return;
Expand Down Expand Up @@ -125,6 +128,7 @@ private void mousePressed(MouseEvent evt) {
if (dragMode == null) {
return;
}
dragging = true;

switch (dragMode) {
case START_AND_END_TIME:
Expand Down Expand Up @@ -161,6 +165,7 @@ private void mousePressed(MouseEvent evt) {


private void mouseReleased(MouseEvent evt) {
dragging = false;
if (!evt.getButton().equals(MouseButton.PRIMARY) || dayEntryView == null || dragMode == null) {
return;
}
Expand Down Expand Up @@ -196,6 +201,12 @@ private void mouseDragged(MouseEvent evt) {
return;
}

if (dayView.getDraggedEntry() == null) {
// we might see "mouse dragged" events close before "mouse pressed". in this case, our drag/dro handling
// has not been fully initialized yet.
return;
}

switch (dragMode) {
case START_TIME:
switch (handle) {
Expand Down