Esempio n. 1
0
	//----------
	void Controller::keyPressed(ofKeyEventArgs & args) {
		if (!initialised)
			return;

		if (!this->activeDialog) {
			if (args.key == 'f')
				this->toggleFullscreen();
			if (args.key == 'm')
				this->toggleMaximised();
		}

		auto currentPanel = this->currentPanel.lock();
		KeyboardArguments action(args, KeyboardArguments::Pressed, currentPanel);
		if (this->activeDialog) {
			if (args.key == OF_KEY_ESC) {
				this->closeActiveDialog();
			}
			else {
				this->activeDialog->keyboardAction(action);
			}
		}
		else {
			if (this->maximised) {
				//if something is maximised, only it get the key press
				currentPanel->keyboardAction(action);
			}
			else {
				//otherwise everything visible gets the key press
				rootGroup->keyboardAction(action);
			}
		}
	}
Esempio n. 2
0
		//---------
		SharedViewServer::SharedViewServer() {
			this->onUpdate += [this](ofxCvGui::UpdateArguments &) {
				auto newFocus = this->focusThisFrame.lock();
				if (newFocus) {
					this->focus = newFocus;
					newFocus->getHostedView()->setBounds(this->getLocalBounds());
					this->focusThisFrame.reset();
				}

				auto focus = this->focus.lock();
				if (focus) {
					auto view = focus->getHostedView();
					if (view) {
						view->update();
					}
				}
			};

			this->onDraw += [this](ofxCvGui::DrawArguments & args) {
				auto focus = this->focus.lock();
				if (focus) {
					auto view = focus->getHostedView();
					if (view) {
						view->draw(args);
					}
				}
			};

			this->onMouse += [this](ofxCvGui::MouseArguments & args) {
				auto focus = this->focus.lock();
				if (focus) {
					auto view = focus->getHostedView();
					if (view) {
						view->mouseAction(args);
					}
				}
			};

			this->onKeyboard += [this](ofxCvGui::KeyboardArguments & args) {
				auto focus = this->focus.lock();
				if (focus) {
					auto view = focus->getHostedView();
					if (view) {
						view->keyboardAction(args);
					}
				}
			};

			this->onBoundsChange += [this](ofxCvGui::BoundsChangeArguments & args) {
				auto focus = this->focus.lock();
				if (focus) {
					auto view = focus->getHostedView();
					if (view) {
						view->setBounds(this->getLocalBounds());
					}
				}
			};
		}
			void keyboard::__winnt__readKeyboard(RAWINPUT* rawDevice)
			{
				// Local variable(s):
				keyboardActionType actionType;

				auto key = (keyboardKey)rawDevice->data.keyboard.VKey;
				bool isDown = keyEnabled(key);
				
				if ((rawDevice->data.keyboard.Flags & RI_KEY_BREAK) > 0)
				{
					// If the key is currently up, release/disable it.
					if (isDown)
						disableKey(key);

					actionType = ACTION_TYPE_HIT;
				}
				else // if ((rawDevice->data.keyboard.Flags & RI_KEY_MAKE) > 0)
				{
					// Check if this event is worth logging:
					if (isDown)
						return;

					actionType = ACTION_TYPE_DOWN;

					// Enable/hold this key, so we don't
					// log it again until it's been released.
					enableKey(key);
				}

				actionQueue.push_back(keyboardAction(key, actionType));

				#ifdef KEYBOARD_DEBUG
					deviceInfo << "Detected key: " << rawDevice->data.keyboard.VKey << ", actionType: " << actionType << endl;
				#endif

				return;
			}
Esempio n. 4
0
void Animation::keyBoardFunc(unsigned char c, int x, int y) {
	keyboardAction(c);
}