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 41223 - incorrect behavior of `Delete` item in editor (context menu and main menu)
Summary: incorrect behavior of `Delete` item in editor (context menu and main menu)
Status: RESOLVED WONTFIX
Alias: None
Product: editor
Classification: Unclassified
Component: Actions/Menu/Toolbar (show other bugs)
Version: 3.x
Hardware: Other Other
: P4 blocker (vote)
Assignee: issues@editor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-23 14:54 UTC by Unknown
Modified: 2009-11-02 10:56 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Unknown 2004-03-23 14:54:10 UTC
Description: 


Name: akR10234			Date: 03/18/2004


Item 'Delete' in context menu should be disabled (as 'Cut' or 'Copy')
if nothing selected in file editor.
Now 'Delete' is always enabled and emulates pushing 'Delete' button on
keyboard. So, if nothing is selected it deletes a letter on the left
from the cursor. This is not a usual behavior.

======================================================================

A comment.
Comment 1 Miloslav Metelka 2004-03-25 09:50:55 UTC
We currently plan to remove the "Delete" menu item from editor's popup
completely as part of revisiting of the editor's popup menu. In
practice the "Delete" item is never used as the user is unsure what
gets deleted whether e.g. it wouldn't delete the whole file etc.
 Gabo can have more information regarding this.
Comment 2 Martin Roskanin 2004-08-06 13:03:07 UTC
Already fixed in the [maintrunk]

Delete item has been removed from context menu
Comment 3 Unknown 2004-09-19 02:45:04 UTC
Even though the item has been removed from context menu, the behaviour
still exists with respect to the 'Delete' item in the main menu.

The standard behaviour exhibited by other applications like netscape
editor etc as follows:
- Delete menu item is disabled (whether in main menu or context menu)
if there is no selection in the editor
- Delete menuitem is associated with the 'Del' key
- The key itself works whether there is any selection of not,  by
deleteing the char at cursor.

In netbeans 'Delete' menuitem is enabled even when there is no
selection in the editor.

See also: http://www.netbeans.org/issues/show_bug.cgi?id=25763
   Additional Comments From Miloslav Metelka 2002-07-19 01:04 PDT 
   After personal meeting we've agreed that the change in semantics
   of the DeleteAction (will remove single char if there is no 
   selection) is OK so the binding to deleteNextCharAction can be 
   retained.
The above is probably okay; perhaps what needs to happen is to disable
the Delete menuitem/toolbar.
Comment 4 Martin Roskanin 2004-10-13 09:55:04 UTC
DefaultEditorKit.deleteNextCharAction instead of editor's
"remove-selection" is putted into the ActionMap in CloneableEditor.

Suggested solutions:

First: put actions to ActionMap before kit creation and to pane action
map not TC actionMap. Then we will be able to replace
DefaultEditorKit.deleteNextCharAction with "remove-selection" during
kit creation in editor module.
Index: src/org/openide/text/CloneableEditor.java
===================================================================
RCS file: /cvs/openide/src/org/openide/text/CloneableEditor.java,v
retrieving revision 1.80
diff -r1.80 CloneableEditor.java
183a184,196
>         // Init action map: cut,copy,delete,paste actions.
>         javax.swing.ActionMap am = getActionMap();
>         //#43157 - editor actions need to be accessible from outside
using the TopComponent.getLookup(ActionMap.class) call.
>         // used in main menu enabling/disabling logic.
>         javax.swing.ActionMap paneMap = pane.getActionMap();
>         am.setParent(paneMap);
>         
>         paneMap.put(DefaultEditorKit.cutAction,
getAction(DefaultEditorKit.cutAction));
>         paneMap.put(DefaultEditorKit.copyAction,
getAction(DefaultEditorKit.copyAction));
>         paneMap.put("delete",
getAction(DefaultEditorKit.deleteNextCharAction)); // NOI18N
>         paneMap.put(DefaultEditorKit.pasteAction,
getAction(DefaultEditorKit.pasteAction));
> 
>         
217,227d229
< 
<         // Init action map: cut,copy,delete,paste actions.
<         javax.swing.ActionMap am = getActionMap();
<         //#43157 - editor actions need to be accessible from outside
using the TopComponent.getLookup(ActionMap.class) call.
<         // used in main menu enabling/disabling logic.
<         am.setParent(pane.getActionMap());
<         
<         am.put(DefaultEditorKit.cutAction,
getAction(DefaultEditorKit.cutAction));
<         am.put(DefaultEditorKit.copyAction,
getAction(DefaultEditorKit.copyAction));
<         am.put("delete",
getAction(DefaultEditorKit.deleteNextCharAction)); // NOI18N
<         am.put(DefaultEditorKit.pasteAction,
getAction(DefaultEditorKit.pasteAction));


OR

Second: check for remove-selection map yourself

Index: src/org/openide/text/CloneableEditor.java
===================================================================
RCS file: /cvs/openide/src/org/openide/text/CloneableEditor.java,v
retrieving revision 1.80
diff -r1.80 CloneableEditor.java
226c226,230
<         am.put("delete",
getAction(DefaultEditorKit.deleteNextCharAction)); // NOI18N
---
>         Action deleteAction = getAction("remove-selection"); //NOI18N
>         if (deleteAction == null){
>             deleteAction =
getAction(DefaultEditorKit.deleteNextCharAction);
>         }
>         am.put("delete", deleteAction); // NOI18N
Comment 5 Milos Kleint 2004-10-14 09:35:04 UTC
i went for solution number one because it's more generic and allows
similar changes to be done in the future for other actions.
Comment 6 Martin Roskanin 2004-10-14 12:30:41 UTC
editor part wasn't implemented yet... taking back
Comment 7 Martin Roskanin 2004-10-14 13:31:15 UTC
fixed in [maintrunk]

/cvs/editor/libsrc/org/netbeans/editor/BaseKit.java,v  <--  BaseKit.java
new revision: 1.122; previous revision: 1.121

/cvs/editor/src/org/netbeans/modules/editor/NbEditorUI.java,v  <-- 
NbEditorUI.java
new revision: 1.30; previous revision: 1.29
Comment 8 Martin Roskanin 2005-11-17 15:06:12 UTC
reopening, due to fix of issue #68879
We need to find a different solution
Comment 9 Vitezslav Stejskal 2007-01-07 22:42:28 UTC
Still reproducible in main trunk. We could probably create a menu-bar equivalent
of editor's 'Delete selection' action and use it in the Edit menu instead of
hacking the 'Delete' action.
Comment 10 Jan Becicka 2008-02-15 13:03:43 UTC
Minor issue. Mato will hardly fix it.
Comment 11 David Strupl 2009-03-31 15:47:43 UTC
Resolving all issues with milestone "future" as LATER. If you feel strongly that
it should be implemented please reopen and set the target milestone to "next".
Comment 12 Quality Engineering 2009-11-02 10:56:20 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX