Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

switch tab with keyboard

Questions related to using nuBuilder Forte.
Post Reply
Timo
Posts: 221
Joined: Thu Mar 15, 2018 9:26 pm
Has thanked: 1 time

switch tab with keyboard

Unread post by Timo »

Hello,

Is there a keyboard shortcut to switch between tabs? Like ctrl + left would move to the next tab on an edit screen and ctrl + right to the previous one.
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: switch tab with keyboard

Unread post by toms »

Hi,

Ctrl-left-arrow and Ctrl-right-arrow are already used to skip to the next or previous word. Therefore I'd rather use the ctrl+shift+left-arrow and ctrl+shift+right-arrow combinations.

Add this Javascript code in the Header under Home ► Setup

Code: Select all

function initNextTabShortcuts() {

//  Ctrl + Left | Ctrl + Right Keypress -> Move to previous/next tab
document.onkeydown = function(e) {
  e = e || window.event;
  var keyCode = e.keyCode || e.which,
      arrow = {left: 37, right: 39};

  if(nuFormType() == 'edit'){
  if (e.ctrlKey && e.shiftKey) {
    switch (keyCode) {
      case arrow.left:
        selectNextTab(-1);
        break;
      case arrow.right:
        selectNextTab(1);
        break;
    }
  }
  }
}

function selectNextPrevTab(i) {
	var selectedTab = $('.nuTabSelected')[0].id.substring(5);
	var nextTab = parseInt(selectedTab) + i;
	var e = document.getElementById('nuTab' + nextTab);
	if(e != null) {
		nuSelectTab(e);
	}
}

function nuOnLoad() {
	initNextPrevTabShortcuts();
}
Timo
Posts: 221
Joined: Thu Mar 15, 2018 9:26 pm
Has thanked: 1 time

Re: switch tab with keyboard

Unread post by Timo »

Thanks mate!
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: switch tab with keyboard

Unread post by admin »

.
Post Reply