First step to generate the keyboard event directly on the correct widget
This commit is contained in:
parent
e438b70f0e
commit
6e92491a9f
@ -25,6 +25,7 @@
|
||||
|
||||
#include <ewolDebug.h>
|
||||
#include <etkString.h>
|
||||
#include <ewolWidgetManager.h>
|
||||
#include <guiX11.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -642,17 +643,25 @@ namespace guiAbstraction {
|
||||
break;
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
EWOL_DEBUG("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" ");
|
||||
//EWOL_DEBUG("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" ");
|
||||
{
|
||||
char buf[11];
|
||||
KeySym keysym;
|
||||
XComposeStatus status;
|
||||
int count = XLookupString(&event.xkey, buf, 10, &keysym, &status);
|
||||
buf[count] = '\0';
|
||||
if(event.type == KeyPress) {
|
||||
// TODO : set the char here...
|
||||
} else {
|
||||
// TODO : set the char here...
|
||||
// Get the current Focused Widget :
|
||||
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
|
||||
if (NULL != tmpWidget) {
|
||||
if(event.type == KeyPress) {
|
||||
// TODO : set the char here...
|
||||
EWOL_DEBUG("X11 PRESSED : \"" << buf << "\" size=" << count);
|
||||
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, buf);
|
||||
} else {
|
||||
// TODO : set the char here...
|
||||
EWOL_DEBUG("X11 Release : \"" << buf << "\" size=" << count);
|
||||
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, buf);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ void generatePolyGone(etk::VectorType<coord2D_ts> & input, etk::VectorType<coord
|
||||
return;
|
||||
}
|
||||
coord2D_ts basePoint = input[0];
|
||||
// TODO : Regenerate a linear poligone generation
|
||||
for (int32_t iii=1; iii<input.Size()-1; iii++) {
|
||||
output.PushBack(basePoint);
|
||||
output.PushBack(input[iii]);
|
||||
@ -451,6 +452,7 @@ void ewol::OObject2DColored::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w,
|
||||
|
||||
void ewol::OObject2DColored::RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness)
|
||||
{
|
||||
// TODO : This did not manage the thickness of the line ...
|
||||
Line(x, y, x+w, y, thickness);
|
||||
Line(x+w, y, x+w, y+h, thickness);
|
||||
Line(x+w, y+h, x, y+h, thickness);
|
||||
@ -552,6 +554,7 @@ void ewol::OObject2DColored::Disc(etkFloat_t x, etkFloat_t y, etkFloat_t radius)
|
||||
nbOcurence = 15;
|
||||
}
|
||||
|
||||
// TODO : Generate a poligone instead if this ...
|
||||
for (int32_t iii=0; iii<nbOcurence; iii++) {
|
||||
SetPoint(x, y);
|
||||
|
||||
@ -588,7 +591,7 @@ void ewol::OObject2DColored::DiscPart(etkFloat_t x, etkFloat_t y, etkFloat_t rad
|
||||
nbOcurence = 15;
|
||||
}
|
||||
|
||||
|
||||
// TODO : Generate a poligone instead if this ...
|
||||
for (int32_t iii=0; iii<nbOcurence; iii++) {
|
||||
SetPoint(x, y);
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <widget/ewolButton.h>
|
||||
|
||||
#include <ewolOObject.h>
|
||||
|
||||
#include <ewolWidgetManager.h>
|
||||
|
||||
|
||||
const char * const ewolEventButtonPressed = "ewol Button Pressed";
|
||||
@ -49,6 +49,7 @@ void ewol::Button::Init(void)
|
||||
m_textColorBg.green = 0.0;
|
||||
m_textColorBg.blue = 0.0;
|
||||
m_textColorBg.alpha = 0.25;
|
||||
SetCanHaveFocus(true);
|
||||
}
|
||||
|
||||
ewol::Button::Button(void)
|
||||
@ -172,8 +173,23 @@ bool ewol::Button::OnEventArea(const char * generateEventId, etkFloat_t x, etkFl
|
||||
if(ewolEventButtonPressed == generateEventId) {
|
||||
EWOL_INFO("BT pressed ... " << m_label);
|
||||
eventIsOK = true;
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
} else if(ewolEventButtonEnter == generateEventId) {
|
||||
OnRegenerateDisplay();
|
||||
}
|
||||
return eventIsOK;
|
||||
}
|
||||
|
||||
|
||||
bool ewol::Button::OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE])
|
||||
{
|
||||
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
|
||||
if( UTF8_data != NULL
|
||||
&& typeEvent == ewol::EVENT_KB_TYPE_DOWN
|
||||
&& UTF8_data[0] == '\r') {
|
||||
return OnEventArea(ewolEventButtonPressed, -1, -1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,6 +54,7 @@ namespace ewol {
|
||||
public:
|
||||
//virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
|
||||
virtual bool OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y);
|
||||
virtual bool OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <widget/ewolCheckBox.h>
|
||||
|
||||
#include <ewolOObject.h>
|
||||
#include <ewolWidgetManager.h>
|
||||
|
||||
|
||||
const char * ewolEventCheckBoxClicked = "ewol CheckBox Clicked";
|
||||
|
||||
@ -45,6 +47,7 @@ void ewol::CheckBox::Init(void)
|
||||
m_textColorBg.blue = 1.0;
|
||||
m_textColorBg.alpha = 1.0;
|
||||
m_value = false;
|
||||
SetCanHaveFocus(true);
|
||||
}
|
||||
|
||||
ewol::CheckBox::CheckBox(void)
|
||||
@ -109,7 +112,7 @@ void ewol::CheckBox::OnRegenerateDisplay(void)
|
||||
int32_t fontHeight = ewol::GetHeight(fontId);
|
||||
int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str());
|
||||
int32_t posy = (m_size.y - fontHeight - 6)/2 + 3;
|
||||
int32_t posx = (m_size.x - fontWidth - 6)/2 + 25;
|
||||
//int32_t posx = (m_size.x - fontWidth - 6)/2 + 25;
|
||||
tmpText->Text(25, posy+3, m_label.c_str());
|
||||
|
||||
|
||||
@ -151,6 +154,7 @@ bool ewol::CheckBox::OnEventArea(const char * generateEventId, etkFloat_t x, etk
|
||||
bool eventIsOK = false;
|
||||
//EWOL_DEBUG("Receive event : \"" << generateEventId << "\"");
|
||||
if(ewolEventCheckBoxClicked == generateEventId) {
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
EWOL_INFO("CB pressed ... " << m_label);
|
||||
if(true == m_value) {
|
||||
m_value = false;
|
||||
@ -162,3 +166,17 @@ bool ewol::CheckBox::OnEventArea(const char * generateEventId, etkFloat_t x, etk
|
||||
}
|
||||
return eventIsOK;
|
||||
}
|
||||
|
||||
bool ewol::CheckBox::OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE])
|
||||
{
|
||||
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
|
||||
if( UTF8_data != NULL
|
||||
&& typeEvent == ewol::EVENT_KB_TYPE_DOWN
|
||||
&& ( UTF8_data[0] == '\r'
|
||||
|| UTF8_data[0] == ' ')
|
||||
) {
|
||||
return OnEventArea(ewolEventCheckBoxClicked, -1, -1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ namespace ewol {
|
||||
public:
|
||||
//virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
|
||||
virtual bool OnEventArea(const char * generateEventId, etkFloat_t x, etkFloat_t y);
|
||||
virtual bool OnEventKb(eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]);
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user