This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 262731 - [82cat] Multi-caret key binding CTRL+SHIFT+CLICK does not work on Mac OS
Summary: [82cat] Multi-caret key binding CTRL+SHIFT+CLICK does not work on Mac OS
Status: RESOLVED DUPLICATE of bug 262728
Alias: None
Product: editor
Classification: Unclassified
Component: Key bindings (show other bugs)
Version: 8.2
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-08 09:03 UTC by brettryan
Modified: 2016-09-22 11:28 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed patch (3.08 KB, patch)
2016-07-21 23:23 UTC, markiewb
Details | Diff
Proposed patch v2 (3.64 KB, patch)
2016-08-03 18:52 UTC, markiewb
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description brettryan 2016-07-08 09:03:42 UTC
While many of the multi-caret shortcuts seem available, the one for "Add caret and enter multi-caret mode" (CTRL+SHIFT+CLICK) does not seem to be available in the key bindings.

This key binding conflicts with the OS X key binding so must be changed or editable.


Product Version: NetBeans IDE Dev (Build 201607070002)
Java: 1.8.0_92; Java HotSpot(TM) 64-Bit Server VM 25.92-b14
Runtime: Java(TM) SE Runtime Environment 1.8.0_92-b14
System: Mac OS X version 10.11.4 running on x86_64; UTF-8; en_AU (nb)
User directory: /Users/bryan/Library/Application Support/NetBeans/dev
Cache directory: /Users/bryan/Library/Caches/NetBeans/dev

[1]: https://netbeans.org/bugzilla/show_bug.cgi?id=262728
Comment 1 markiewb 2016-07-14 18:44:07 UTC
@brettryan: Which mac-specific key-combination do you propose? 
Please check out other mac tools, which support multi-carets!
Comment 2 brettryan 2016-07-15 00:32:16 UTC
(In reply to markiewb from comment #1)
> @brettryan: Which mac-specific key-combination do you propose?

Cmd+Shift+Click, I would have said Cmd+Click but that of course is go to declaration.

> Please check out other mac tools, which support multi-carets!

One of the most popular editors for OS X based web authors is typically sublimetext [1] which we should aim to provide as smooth a transition as we can for those users.


I mostly raised this bug as a feature request but marked as defect only due to the collision, however; if you like, you can close this bug and not implement the feature but provide a sensible default and refer to issue:262728 [2] instead which I am presently putting together sensible defaults that are closely related to sublime text while also trying (hard I might add) to not conflict with existing NB bindings.

NetBeans IDE is presently getting pretty crowded with shortcuts due to the sheer size of functionality it provides, it's unavoidable. Thus, it does make a few things harder to match closer for users coming from other tools.

Keep an eye on [2] for my suggestions.


 [1]: https://www.sublimetext.com
 [2]: https://netbeans.org/bugzilla/show_bug.cgi?id=262728
Comment 3 brettryan 2016-07-15 01:40:05 UTC
(In reply to markiewb from comment #1)
> @brettryan: Which mac-specific key-combination do you propose? 
> Please check out other mac tools, which support multi-carets!

Ok, check out issue:262728 [1] where I've completed my analysis and research of what does not presently conflict and I think are viable options.


 [1]: https://netbeans.org/bugzilla/show_bug.cgi?id=262728
Comment 5 markiewb 2016-07-21 23:23:47 UTC
Created attachment 161376 [details]
Proposed patch

@brettryan: Please try out the patch! It should work with Cmd+Shift+Click. Please give your feedback. 

I cannot test it on a mac.
Comment 6 brettryan 2016-07-22 01:59:57 UTC
(In reply to markiewb from comment #5)
> @brettryan: Please try out the patch! It should work with Cmd+Shift+Click.
> Please give your feedback. 
> 
> I cannot test it on a mac.

Sure thing, I'm away for the weekend busy getting rather properly drunk. I shall be returning on Monday.
Comment 7 markiewb 2016-07-28 19:11:07 UTC
@brettryan: Can you please review the patch and try it out using your mac!
Comment 8 brettryan 2016-08-03 09:01:18 UTC
Sorry, had been away for a week.

Have just tried it out and it's not working unfortunately. I have debugged and can confirm that the result of isControlShiftDown is actually returning true, it just isn't inserting any additional carets.

This is caused by the isLeftMouseButtonExt(MouseEvent) method which does a check for InputEvent.META_MASK being NOT present. As a consequence it returns false.

I've tested the validity of the logic by commenting out that line:

    private boolean isLeftMouseButtonExt(MouseEvent evt) {
        return (SwingUtilities.isLeftMouseButton(evt)
                && !(evt.isPopupTrigger()));
//                && (evt.getModifiers() & (InputEvent.META_MASK/* | InputEvent.ALT_MASK*/)) == 0);
    }

Which does in fact get the multi-caret support working, however I would need to investigate what the purpose of that check is for, which you might be better equiped to understand :)

Again, sorry for the delay, I'm back up and running and should be able to respond quicker.
Comment 9 markiewb 2016-08-03 18:52:03 UTC
Created attachment 161551 [details]
Proposed patch v2

@brettryan: Try this patch! It is more similar to the BaseCaret-Implementation
Comment 10 brettryan 2016-08-03 21:47:22 UTC
Nah still no go, man.

The difference I can see is that the test is now more inclusive.

    (evt.getModifiers() & (InputEvent.META_MASK | InputEvent.ALT_MASK)) == 0);

is still testing for InputEvent.META_MASK but is now in addition checking existence of InputEvent.ALT_MASK.

What does the check for InputEvent.META_MASK actually do in this context?
Comment 11 Svata Dedic 2016-08-03 21:49:14 UTC
Multicaret owner should review this issue.
Comment 12 markiewb 2016-08-03 21:58:35 UTC
(In reply to Svata Dedic from comment #11)
> Multicaret owner should review this issue.

You are right. Miloslav, can you please help!

@brettryan: Can you please provide the output of "evt.getModifiers()" when you press CMD-Shift on Mac. This might help Miloslav.
Comment 13 brettryan 2016-08-03 23:42:09 UTC
Not sure why, but no keys depressed always produces 0x10 (KeyEvent.VK_SHIFT).

NOTHING   = 0x10 | 10000
SHIFT     = 0x11 | 10001
CMD       = 0x14 | 10100
CMD+SHIFT = 0x15 | 10101

Just to point out the obvious which I mentioned previously. We want to check for META_MASK (0x04), but the problem is with isLeftMouseButtonExt(MouseEvent) doing the reverse.

Here's what's happening.

In mousePressed(MouseEvent) there is a check before entering the main block of the method:

    if (c != null && doc != null && isLeftMouseButtonExt(evt)) {

This check for isLeftMouseButtonExt does the following condition:

        return (SwingUtilities.isLeftMouseButton(evt)
                && !(evt.isPopupTrigger())
                && (evt.getModifiers() & (InputEvent.META_MASK | InputEvent.ALT_MASK)) == 0);

Note here that this is checking that the presence of META_MASK is NOT present (== 0) and because it is, we don't get the main body being executed.

That's what led me to my question. What is the purpose of this check in the first place?
Comment 14 Miloslav Metelka 2016-09-22 09:40:12 UTC
This should be resolved by latest fix of issue #262728.

*** This bug has been marked as a duplicate of bug 262728 ***
Comment 15 brettryan 2016-09-22 11:28:00 UTC
(In reply to Miloslav Metelka from comment #14)
> This should be resolved by latest fix of issue #262728.
> 
> *** This bug has been marked as a duplicate of bug 262728 ***

Agree, though the reasoning for raising the two was the intent of this feature request was to provide support to alter the bindings.