Example #1
0
void CTEKWindow::OnLButtonDown(UINT nFlags, CPoint point)
{
	POINT p;
	HMENU PopupMenu, PopupBase;

	p.x = point.x;
	p.y = point.y;

	// popup menu
	if (ControlKey() && (MainMenu==NULL))
	{
		InitMenu(&PopupMenu);
		InitMenuPopup(EditMenu);
		if (WinMenu!=NULL) {
			InitMenuPopup(WinMenu);
		}
		PopupBase = CreatePopupMenu();
		get_lang_msg("MENU_CONTROL", ts.UIMsg, sizeof(ts.UIMsg), "&File", ts.UILanguageFile);
		AppendMenu(PopupBase, MF_STRING | MF_ENABLED | MF_POPUP,
		           (UINT)GetSubMenu(PopupMenu,0), ts.UIMsg);
		get_lang_msg("TEKMENU_EDIT", ts.UIMsg, sizeof(ts.UIMsg), "&Edit", ts.UILanguageFile);
		AppendMenu(PopupBase, MF_STRING | MF_ENABLED | MF_POPUP,
		           (UINT)EditMenu, ts.UIMsg);
		get_lang_msg("TEKMENU_SETUP", ts.UIMsg, sizeof(ts.UIMsg), "&Setup", ts.UILanguageFile);
		AppendMenu(PopupBase, MF_STRING | MF_ENABLED | MF_POPUP,
		           (UINT)GetSubMenu(PopupMenu,2), ts.UIMsg);
		get_lang_msg("TEKMENU_VTWIN", ts.UIMsg, sizeof(ts.UIMsg), "VT-Wind&ow", ts.UILanguageFile);
		AppendMenu(PopupBase, MF_STRING | MF_ENABLED,
		           ID_TEKVTWIN, ts.UIMsg);
		if (WinMenu!=NULL) {
			get_lang_msg("TEKMENU_WINDOW", ts.UIMsg, sizeof(ts.UIMsg), "&Window", ts.UILanguageFile);
			AppendMenu(PopupBase, MF_STRING | MF_ENABLED | MF_POPUP,
			           (UINT)WinMenu, ts.UIMsg);
		}
		get_lang_msg("TEKMENU_HELP", ts.UIMsg, sizeof(ts.UIMsg), "&Help", ts.UILanguageFile);
		AppendMenu(PopupBase, MF_STRING | MF_ENABLED | MF_POPUP,
		           (UINT)GetSubMenu(PopupMenu,4), ts.UIMsg);
		::ClientToScreen(tk.HWin, &p);
		TrackPopupMenu(PopupBase,TPM_LEFTALIGN | TPM_LEFTBUTTON,
		               p.x,p.y,0,tk.HWin,NULL);
		if (WinMenu!=NULL) {
			DestroyMenu(WinMenu);
			WinMenu = NULL;
		}
		DestroyMenu(PopupBase);
		DestroyMenu(PopupMenu);
		return;
	}

	TEKWMLButtonDown(&tk,&ts,&cv,p);
}
bool InputDeviceAdapterMouse::keyPressed(int keyCode,int modifierMask,const char* string)
{
    bool stateChanged=false;

    if(keyCode==keyboardModeToggleKeyCode)
    {
        keyboardMode=!keyboardMode;
        if(fakeMouseCursor)
        {
            /* Change the glyph renderer's cursor type to a text cursor: */
        }
        else if(keyboardMode)
        {
            /* Change the cursor in all windows to a text cursor: */
            for(int i=0; i<getNumWindows(); ++i)
            {
                VRWindow* win=Vrui::getWindow(i);
                if(win!=0)
                {
                    Cursor cursor=XCreateFontCursor(win->getContext().getDisplay(),XC_xterm);
                    XDefineCursor(win->getContext().getDisplay(),win->getWindow(),cursor);
                    XFreeCursor(win->getContext().getDisplay(),cursor);
                }
            }
        }
        else
        {
            /* Change the cursor in all windows back to the regular: */
            for(int i=0; i<getNumWindows(); ++i)
            {
                VRWindow* win=Vrui::getWindow(i);
                if(win!=0)
                    XUndefineCursor(win->getContext().getDisplay(),win->getWindow());
            }
        }
    }
    else if(keyboardMode)
    {
        /* Process the key event: */
        ControlKeyMap::Iterator ckmIt=controlKeyMap.findEntry(ControlKey(keyCode,modifierMask&(ShiftMask|ControlMask)));
        if(!ckmIt.isFinished())
        {
            /* Store a text control event: */
            textControlEvents.push_back(std::pair<int,GLMotif::TextControlEvent>(nextEventOrdinal,ckmIt->getDest()));
            ++nextEventOrdinal;
        }
        else if(string!=0&&string[0]!='\0')
        {
            /* Store a text event: */
            textEvents.push_back(std::pair<int,GLMotif::TextEvent>(nextEventOrdinal,GLMotif::TextEvent(string)));
            ++nextEventOrdinal;
        }

        stateChanged=true;
    }
    else
    {
        /* Check if the key is a button key: */
        int buttonIndex=getButtonIndex(keyCode);
        if(buttonIndex>=0)
        {
            /* Set button state: */
            int stateIndex=(numButtons+numButtonKeys)*modifierKeyMask+numButtons+buttonIndex;
            stateChanged=changeButtonState(stateIndex,true);
        }

        /* Check if the key is a modifier key: */
        int modifierIndex=getModifierIndex(keyCode);
        if(modifierIndex>=0)
        {
            /* Change current modifier mask: */
            changeModifierKeyMask(modifierKeyMask|(0x1<<modifierIndex));
            stateChanged=true;
        }
    }

    // requestUpdate();

    return stateChanged;
}