예제 #1
0
bool
HippoExplorerBar::processMessage(UINT   message,
                                 WPARAM wParam,
                                 LPARAM lParam)
{
    switch (message) {
        case WM_SHOWWINDOW:
            if (!(BOOL)wParam && ie_) {
                // Notify the contents of the explorer bar that we've
                // been closed so that we leave the chatroom; the
                // page contents are kept around when the bar is closed,
                // so the normal handling when the controls are removed
                // doesn't work. We might want to do something on Show
                // if we wanted to handle the case when the user reopens the
                // bar manual from the menu, but probably we'd want to show
                // some content such as recent links in that case instead
                // of just rejoining the chatroom.
                HRESULT hr = ie_->createInvocation(L"dhBarClosed").run();
            }
            return false;
        case WM_SETFOCUS:
            setHasFocus(true);
            return true;
        case WM_KILLFOCUS:
            setHasFocus(false);
            return true;
        case WM_SIZE:
            if (ie_) {
                RECT rect = { 0, 0, LOWORD(lParam), HIWORD(lParam) };
                ie_->resize(&rect);
            }
        default:
            return false;
    }
}
예제 #2
0
TextBox::TextBox(float x, float y, sf::Font* font, float pWidth) {
	setPosition(x, y);
	setSize(pWidth);
	setHasFocus(false);

	// Set Text field
	Text.setPosition(x + 3, y + 2);
	Text.setCharacterSize(14);

	Text.setFont(*font);
	Text.setColor(sf::Color::Black);
	Text.setStyle(sf::Text::Regular);

}
예제 #3
0
void TextBox::update(sf::Vector2f mouseLoc, sf::Event event) {

	sf::String tmp;

	// User click on the text box
	if (rectangle.getGlobalBounds().contains(mouseLoc)) {
		if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {

			setHasFocus(true);

		}
	}
	// User clicked elsewhere 
	else {
		if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {

			setHasFocus(false);

		}
	}

	// This textbox is in focus
	if (getHasFocus()) {

		// User typed text
		if (event.type == sf::Event::TextEntered) {

			// Limit the number of times a character repeats
			if ((prevEvent == event.text.unicode && 
					reset.getElapsedTime().asMilliseconds() > TYPE_DELAY) ||
					 prevEvent != event.text.unicode) {

				// Handle backspace
				if (event.text.unicode == 8) {

					// Get current text
					tmp = Text.getString();

					// If not blank erase one character then update
					if (tmp != "") {
						tmp.erase(tmp.getSize() - 1, 1);
						Text.setString(tmp);
					}

					// Restart repeat timeout
					reset.restart();

				} 
				// Valid character
				else if (event.text.unicode > 0x21
						&& event.text.unicode < 0x7e) {

					// Get current text
					tmp = Text.getString();
					// Append character
					tmp = tmp + (event.text.unicode);
					// Update text fields
					Text.setString(tmp);

					// Reset repeat timeout
					reset.restart();

				} 
				// Invalid character
				else {
					
				}
			}

			// Remember last character
			prevEvent = event.text.unicode;
		}
	}
}