Tab in CEGUI

BlitzMax Modules Forums/Brucey's Modules/Tab in CEGUI

Should tab be working to change focus from each control?

I also can't seem to record what key is pressed using TCEButtonBase.EventKeyDown event, as I was trying to setup a tab system as a manual workaround.

Any idea how this can be done specifically in cegui?

Thanks

Should tab be working to change focus from each control?

I found this : http://www.cegui.org.uk/wiki/index.php/Tab_Order
which we may want to implement?

Going through that, something doesn't seem right.

Subscribing event..
TCEEditbox(TCEWindowManager.getWindow("LoginWindow/txtUsername")).subscribeEvent(TCEButtonBase.EventCharacterKey, Event_KeyTest)


Keytest:
Function Event_KeyTest:Int(args:TCEEventArgs)
	Notify TCEKeyEventArgs(args).getCodepoint()
	Return True
End Function


Doesn't seem to return the proper codepoint...coming from the link you sent me:

in..(no need to go through, just for reference)
bool TabNavigation::_onCharacterKey(const CEGUI::EventArgs& e)
{
	// Handle Tab (next) and Shift+Tab (previous) widget navigation
	assert(_tabNavigation.size() && "Don't simply call setParent(), also call addWidget()");
	if(static_cast(e).codepoint == 9) // Tab or Shift+Tab
	{
		// Identify who currently has the focus
		CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
		std::vector::iterator itFocus, itCurrent;
		if(_lastKnownFocus != _tabNavigation.end() && wmgr.getWindow(*_lastKnownFocus)->isActive())
		{
			// The last known focus is still in focus
			itCurrent = _lastKnownFocus;
		}
		else
		{
			// Figure out who (if anyone) has the focus
			for(itCurrent = _tabNavigation.begin(); itCurrent != _tabNavigation.end(); itCurrent++)
			{
				if(wmgr.getWindow(*itCurrent)->isActive())
				{
					// Found who has the focus
					break;
				}
			}
			if(itCurrent == _tabNavigation.end())
			{
				// We did not find who had the focus
				// Someone not in our list of monitored widgets has STOLEN the focus!
				// Use the last known focus or, if that's invalid, the first widget
				itCurrent = _lastKnownFocus != _tabNavigation.end() ? _lastKnownFocus : _tabNavigation.begin();
			}
		}

		// Change the focus
		itFocus = itCurrent; // The search starts from the currently focused
		CEGUI::Window* newWidget = 0;
		do
		{
			if(static_cast(e).sysKeys & CEGUI::Shift)
			{
				// Search previous
				if(itFocus == _tabNavigation.begin())
					itFocus = --_tabNavigation.end();
				else
					itFocus--;
			}
			else
			{
				// Search next
				itFocus++;
				if(itFocus == _tabNavigation.end())
					itFocus = _tabNavigation.begin();
			}
			newWidget = wmgr.getWindow(*itFocus);
			if(newWidget->isVisible() && !newWidget->isDisabled())
			{
				// We have found a valid focus target
				_lastKnownFocus = itFocus;
				break;
			}
			newWidget = 0;
		} while(itFocus != itCurrent); // Iterate while we're on a different widget

		if(newWidget)
		{
			// Remove the focus from this widget
			HACKED_FOCUS_LOSS(*itCurrent);

			// Give the focus to this widget
			newWidget->activate();
			HACKED_FOCUS_GAIN(newWidget->getName());
			return true;
		}
	}
	return false;
}


contains this line:

if(static_cast(e).codepoint == 9) // Tab or Shift+Tab



my previously mentioned: "Notify TCEKeyEventArgs(args).getCodepoint()"

isn't returning 9 when I press tab. It always returns the same number no matter what key I press. I would have no problem implimenting my own tab system if I could figure out what key is being pressed in this event, or even event_keyup/event_keydown events, but I can't seem to get beyond this part.

Eh... couldn't get anything working for keycodes, so I just half-assed it and used keypressed(key_tab) and checking which controls were active and going from there.