示例#1
0
bool ewol::widget::Button::onEventEntry(const ewol::event::Entry& _event) {
	//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
	if(    _event.getType() == gale::key::keyboard::character
	    && _event.getStatus() == gale::key::status::down
	    && _event.getChar() == '\r') {
		signalEnter.emit();
		return true;
	}
	return false;
}
示例#2
0
bool appl::TextViewer::onEventEntry(const ewol::event::Entry& _event) {
	if (m_buffer == nullptr) {
		return false;
	}
	// First call plugin
	if (m_pluginManager->onEventEntry(*this, _event) == true) {
		markToRedraw();
		return true;
	}
	// just forward event  == > manage directly in the buffer
	if (_event.getType() == gale::key::keyboard::character) {
		//APPL_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent);
		if (_event.getStatus() != gale::key::status::down) {
			return false;
		}
		char32_t localValue = _event.getChar();
		if (localValue == u32char::Return) {
			if (true == _event.getSpecialKey().getShift()) {
				localValue = u32char::CarrierReturn;
			}
		} else if (localValue == u32char::Suppress ) {
			//APPL_INFO("keyEvent : <suppr> pos=" << m_cursorPos);
			if (m_buffer->hasTextSelected()) {
				remove();
			} else {
				appl::Buffer::Iterator pos = m_buffer->cursor();
				appl::Buffer::Iterator posEnd = pos;
				++posEnd;
				replace("", pos, posEnd);
			}
			return true;
		} else if (localValue == u32char::Delete) {
			//APPL_INFO("keyEvent : <del> pos=" << m_cursorPos);
			if (m_buffer->hasTextSelected()) {
				remove();
			} else {
				appl::Buffer::Iterator pos = m_buffer->cursor();
				appl::Buffer::Iterator posEnd = pos;
				--pos;
				replace("", pos, posEnd);
			}
			return true;
		}
		m_buffer->setSelectMode(false);
		// normal adding char ...
		char output[5];
		output[0] = '0';
		u32char::convertUtf8(localValue, output);
		if (    m_buffer->hasTextSelected() == false
		     && _event.getSpecialKey().getInsert() == true) {
			appl::Buffer::Iterator pos = m_buffer->cursor();
			appl::Buffer::Iterator posEnd = pos;
			++posEnd;
			replace(output, pos, posEnd);
			//TODO : choisce UTF  ... replace(localValue, pos, posEnd);
		} else {
			std::string myString = output;
			write(myString);
		}
		return true;
	}
	// move events ...
	if (_event.getStatus() == gale::key::status::down) {
		// selection when shift is set:
		m_buffer->setSelectMode(_event.getSpecialKey().getShift());
		// check selection event ...
		switch(_event.getType()) {
			case gale::key::keyboard::insert:
				m_insertMode = m_insertMode==true?false:true;
				markToRedraw();
				break;
			case gale::key::keyboard::left:
				//APPL_INFO("keyEvent : <LEFT>");
				moveCursorLeft();
				break;
			case gale::key::keyboard::right:
				//APPL_INFO("keyEvent : <RIGHT>");
				moveCursorRight();
				break;
			case gale::key::keyboard::up:
				//APPL_INFO("keyEvent : <UP>");
				moveCursorUp(1);
				break;
			case gale::key::keyboard::down:
				//APPL_INFO("keyEvent : <DOWN>");
				moveCursorDown(1);
				break;
			case gale::key::keyboard::pageUp:
				//APPL_INFO("keyEvent : <PAGE-UP>");
				moveCursorUp(15); // TODO : Set the real number of line ...
				break;
			case gale::key::keyboard::pageDown:
				//APPL_INFO("keyEvent : <PAGE-DOWN>");
				moveCursorDown(15); // TODO : Set the real number of line ...
				break;
			case gale::key::keyboard::start:
				//APPL_INFO("keyEvent : <Start of line>");
				moveCursorLeft(moveEnd);
				break;
			case gale::key::keyboard::end:
				//APPL_INFO("keyEvent : <End of line>");
				moveCursorRight(moveEnd);
				break;
			default:
				break;
		}
		return true;
	}
	return false;
}