Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Overwrite default keybindings
Overwrite default keybindings [message #1061625] Mon, 03 June 2013 10:59 Go to next message
Aljoscha Steffens is currently offline Aljoscha Steffens
Messages: 302
Registered: November 2012
Senior Member
Hi,
when I define my own keybindings according to http://www.vogella.com/articles/EclipseRCP/article.html#keybindingsthey do not overwrite the default ones. If I for example create a Ctrl+A keybinding and press it, a small yellow window pops up which lets me decide between my keybinding and the default one.

All solutions that I found were for eclipse 3.XX (for example http://eclipsesource.com/blogs/2008/07/18/tip-suppressing-keybindings/)
Re: Overwrite default keybindings [message #1065064 is a reply to message #1061625] Mon, 24 June 2013 08:14 Go to previous messageGo to next message
Aljoscha Steffens is currently offline Aljoscha Steffens
Messages: 302
Registered: November 2012
Senior Member
Does no one have this problem?
Re: Overwrite default keybindings [message #1065070 is a reply to message #1065064] Mon, 24 June 2013 08:39 Go to previous messageGo to next message
Bastian Wagenfeld is currently offline Bastian Wagenfeld
Messages: 162
Registered: January 2013
Senior Member
Hi,

I just remove the original KeyBindings in my code by iterating over the contexts:
for (MBindingTable table : app.getBindingTables()) {
			List<MKeyBinding> toRemove = new ArrayList<>();
			for (MKeyBinding binding : table.getBindings()) {
				if (binding.getKeySequence().equals("CTRL+A")
						&& (binding.getElementId() == null || !binding
								.getElementId().contains("overwrite"))) {
					toRemove.add(binding);
				}
			}
			table.getBindings().removeAll(toRemove);
		}


Maybe this isn't the best approach, but it works for me Smile

Bastian
Re: Overwrite default keybindings [message #1065296 is a reply to message #1065070] Tue, 25 June 2013 09:30 Go to previous messageGo to next message
Aljoscha Steffens is currently offline Aljoscha Steffens
Messages: 302
Registered: November 2012
Senior Member
This yellow window still pops up. I removed all the bindings with elementId == null, so that just my bindings remain, but nothing changes.
It's like the binding context is not being updated.

[Updated on: Tue, 25 June 2013 09:32]

Report message to a moderator

Re: Overwrite default keybindings [message #1065732 is a reply to message #1065296] Thu, 27 June 2013 09:58 Go to previous message
Aljoscha Steffens is currently offline Aljoscha Steffens
Messages: 302
Registered: November 2012
Senior Member
Ah sorry, I changed the code a little because I thought I needed it differently. Your code works fine! Thanks!!!!!!!
Just for completion (if you want to remove more than one binding):
This does not work:
		for (MBindingTable table : app.getBindingTables()) {
			List<MKeyBinding> toRemove = new ArrayList<>();			
			for (MKeyBinding binding : table.getBindings()) {
				if (binding.getKeySequence().equals("CTRL+A")
						&& (binding.getElementId() == null || !binding
								.getElementId().contains("overwrite"))) {
					toRemove.add(binding);
				}
				else if (binding.getKeySequence().equals("CTRL+Z")
						&& (binding.getElementId() == null || !binding
						.getElementId().contains("overwrite"))) {
					toRemove.add(binding);
				}
			}
			table.getBindings().removeAll(toRemove);
		}


this does:
for (MBindingTable table : app.getBindingTables()) {
			List<MKeyBinding> toRemove = new ArrayList<>();			
			for (MKeyBinding binding : table.getBindings()) {
				if (binding.getKeySequence().equals("CTRL+A")
						&& (binding.getElementId() == null || !binding
								.getElementId().contains("overwrite"))) {
					toRemove.add(binding);
				}
			}
			table.getBindings().removeAll(toRemove);
			
			for (MKeyBinding binding : table.getBindings()) {
				if (binding.getKeySequence().equals("CTRL+Z")
						&& (binding.getElementId() == null || !binding
								.getElementId().contains("overwrite"))) {
					toRemove.add(binding);
				}
			}
			table.getBindings().removeAll(toRemove);
		}


[Updated on: Thu, 27 June 2013 10:09]

Report message to a moderator

Previous Topic:Using e3 properties view in e4 RCP application
Next Topic:AbstractContributionFactory doesn't work anymore
Goto Forum:
  


Current Time: Wed Sep 17 05:40:02 GMT 2014

Powered by FUDForum. Page generated in 0.02643 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software