Manage shortcut is correct and the keyboard all time generate the good key event...

This commit is contained in:
Edouard Dupin 2012-02-24 12:46:30 +01:00
parent 6cbe46a105
commit 3bb73288c6
7 changed files with 96 additions and 70 deletions

View File

@ -42,7 +42,7 @@ class EventShortCut {
static etk::VectorType<EventShortCut *> l_inputShortCutEvent; //!< generic short-cut event static etk::VectorType<EventShortCut *> l_inputShortCutEvent; //!< generic short-cut event
void ewol::shortCut::Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString& data) void ewol::shortCut::Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString data)
{ {
EventShortCut * newEvent = new EventShortCut(); EventShortCut * newEvent = new EventShortCut();
if (NULL == newEvent) { if (NULL == newEvent) {
@ -61,7 +61,7 @@ void ewol::shortCut::Add(bool shift, bool control, bool alt, bool meta, uniChar_
} }
void ewol::shortCut::Add(char * descriptiveString, const char * generateEventId, etk::UString& data) void ewol::shortCut::Add(const char * descriptiveString, const char * generateEventId, etk::UString data)
{ {
if( NULL==descriptiveString if( NULL==descriptiveString
|| 0==strlen(descriptiveString)) || 0==strlen(descriptiveString))
@ -76,7 +76,7 @@ void ewol::shortCut::Add(char * descriptiveString, const char * generateEventId,
// parsing of the string : // parsing of the string :
//"ctrl+shift+alt+meta+s" //"ctrl+shift+alt+meta+s"
char * tmp = strstr(descriptiveString, "ctrl"); const char * tmp = strstr(descriptiveString, "ctrl");
if(NULL != tmp) { if(NULL != tmp) {
control = true; control = true;
} }
@ -123,8 +123,11 @@ void ewol::shortCut::UnInit(void)
bool ewol::shortCut::Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue) bool ewol::shortCut::Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, bool isDown)
{ {
if (unicodeValue >= 'A' && unicodeValue <='Z') {
unicodeValue += 'a' - 'A';
}
//EWOL_INFO("Try to find generic shortcut ..."); //EWOL_INFO("Try to find generic shortcut ...");
for(int32_t iii=l_inputShortCutEvent.Size()-1; iii>=0; iii--) { for(int32_t iii=l_inputShortCutEvent.Size()-1; iii>=0; iii--) {
if( l_inputShortCutEvent[iii]->shift == shift if( l_inputShortCutEvent[iii]->shift == shift
@ -133,7 +136,9 @@ bool ewol::shortCut::Process(bool shift, bool control, bool alt, bool meta, uniC
&& l_inputShortCutEvent[iii]->meta == meta && l_inputShortCutEvent[iii]->meta == meta
&& l_inputShortCutEvent[iii]->UnicodeValue == unicodeValue) && l_inputShortCutEvent[iii]->UnicodeValue == unicodeValue)
{ {
ewol::widgetMessageMultiCast::Send(-1, l_inputShortCutEvent[iii]->generateEventId, l_inputShortCutEvent[iii]->eventData); if (isDown) {
ewol::widgetMessageMultiCast::Send(-1, l_inputShortCutEvent[iii]->generateEventId, l_inputShortCutEvent[iii]->eventData);
} // no else
return true; return true;
} }
} }

View File

@ -32,7 +32,7 @@ namespace ewol {
namespace shortCut { namespace shortCut {
void Init(void); void Init(void);
void UnInit(void); void UnInit(void);
bool Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue); bool Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, bool isDown);
}; };
}; };

View File

@ -75,16 +75,6 @@ typedef struct {
float y; float y;
} eventInputState_ts; } eventInputState_ts;
typedef struct {
bool isDown;
uniChar_t myChar;
} eventKeyboardKey_ts;
typedef struct {
bool isDown;
ewol::eventKbMoveType_te move;
} eventKeyboardMove_ts;
void EWOL_NativeEventInputMotion(int pointerID, float x, float y ); void EWOL_NativeEventInputMotion(int pointerID, float x, float y );
void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y ); void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y );
void EWOL_NativeResize(int w, int h ); void EWOL_NativeResize(int w, int h );
@ -157,15 +147,16 @@ static void* BaseAppEntry(void* param)
} }
break; break;
case THREAD_KEYBORAD_KEY: case THREAD_KEYBORAD_KEY:
EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY"); //EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
{ {
eventKeyboardKey_ts * tmpData = (eventKeyboardKey_ts*)data.data; eventKeyboardKey_ts * tmpData = (eventKeyboardKey_ts*)data.data;
guiAbstraction::SendKeyboardEvent(tmpData->isDown, tmpData->myChar); if (false==ewol::shortCut::Process(tmpData->special.shift, tmpData->special.ctrl, tmpData->special.alt, tmpData->special.meta, tmpData->myChar, tmpData->isDown)) {
//if (false==ewol::shortCut::Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue)) { ... } guiAbstraction::SendKeyboardEvent(tmpData->isDown, tmpData->myChar);
}
} }
break; break;
case THREAD_KEYBORAD_MOVE: case THREAD_KEYBORAD_MOVE:
EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_MOVE"); //EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_MOVE");
{ {
eventKeyboardMove_ts * tmpData = (eventKeyboardMove_ts*)data.data; eventKeyboardMove_ts * tmpData = (eventKeyboardMove_ts*)data.data;
guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move); guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
@ -313,20 +304,14 @@ void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y )
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_STATE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputState_ts) ); ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_STATE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputState_ts) );
} }
void EWOL_ThreadKeyboardEvent(bool isDown, uniChar_t keyInput) void EWOL_ThreadKeyboardEvent(eventKeyboardKey_ts& keyInput)
{ {
eventKeyboardKey_ts tmpData; ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_KEY, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(eventKeyboardKey_ts) );
tmpData.isDown = isDown;
tmpData.myChar = keyInput;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_KEY, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventKeyboardKey_ts) );
} }
void EWOL_ThreadKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput) void EWOL_ThreadKeyboardEventMove(eventKeyboardMove_ts& keyInput)
{ {
eventKeyboardMove_ts tmpData; ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_MOVE, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(eventKeyboardMove_ts) );
tmpData.isDown = isDown;
tmpData.move = keyInput;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_MOVE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventKeyboardMove_ts) );
} }
void EWOL_ThreadEventHide(void) void EWOL_ThreadEventHide(void)

View File

@ -37,8 +37,34 @@ void EWOL_ThreadSetArchiveDir(int mode, const char* str);
void EWOL_ThreadResize(int w, int h ); void EWOL_ThreadResize(int w, int h );
void EWOL_ThreadEventInputMotion(int pointerID, float x, float y); void EWOL_ThreadEventInputMotion(int pointerID, float x, float y);
void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y); void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y);
void EWOL_ThreadKeyboardEvent(bool isDown, uniChar_t keyInput);
void EWOL_ThreadKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput);
typedef struct {
bool capLock;
bool shift;
bool ctrl;
bool meta;
bool alt;
bool altGr;
bool verNum;
bool insert;
} eventSpecialKey_ts;
typedef struct {
bool isDown;
uniChar_t myChar;
eventSpecialKey_ts special;
} eventKeyboardKey_ts;
typedef struct {
bool isDown;
ewol::eventKbMoveType_te move;
eventSpecialKey_ts special;
} eventKeyboardMove_ts;
void EWOL_ThreadKeyboardEvent(eventKeyboardKey_ts& keyInput);
void EWOL_ThreadKeyboardEventMove(eventKeyboardMove_ts& keyInput);
void EWOL_ThreadEventHide(void); void EWOL_ThreadEventHide(void);

View File

@ -78,14 +78,7 @@ static int attrListDbl[] = {
None None
}; };
extern bool guiKeyBoardMode_CapLock; static eventSpecialKey_ts guiKeyBoardMode;
extern bool guiKeyBoardMode_Shift;
extern bool guiKeyBoardMode_Ctrl;
extern bool guiKeyBoardMode_Meta;
extern bool guiKeyBoardMode_Alt;
extern bool guiKeyBoardMode_AltGr;
extern bool guiKeyBoardMode_VerNum;
extern bool guiKeyBoardMode_Insert;
extern "C" { extern "C" {
@ -475,48 +468,48 @@ void X11_Run(void)
EWOL_DEBUG("eventKey : " << event.xkey.keycode << " state : " << event.xkey.state); EWOL_DEBUG("eventKey : " << event.xkey.keycode << " state : " << event.xkey.state);
if (event.xkey.state & (1<<0) ) { if (event.xkey.state & (1<<0) ) {
//EWOL_DEBUG(" Special Key : SHIFT"); //EWOL_DEBUG(" Special Key : SHIFT");
guiKeyBoardMode_Shift = true; guiKeyBoardMode.shift = true;
} else { } else {
guiKeyBoardMode_Shift = false; guiKeyBoardMode.shift = false;
} }
if (event.xkey.state & (1<<1) ) { if (event.xkey.state & (1<<1) ) {
//EWOL_DEBUG(" Special Key : CAPS_LOCK"); //EWOL_DEBUG(" Special Key : CAPS_LOCK");
guiKeyBoardMode_CapLock = true; guiKeyBoardMode.capLock = true;
} else { } else {
guiKeyBoardMode_CapLock = false; guiKeyBoardMode.capLock = false;
} }
if (event.xkey.state & (1<<2) ) { if (event.xkey.state & (1<<2) ) {
//EWOL_DEBUG(" Special Key : Ctrl"); //EWOL_DEBUG(" Special Key : Ctrl");
guiKeyBoardMode_Ctrl = true; guiKeyBoardMode.ctrl = true;
} else { } else {
guiKeyBoardMode_Ctrl = false; guiKeyBoardMode.ctrl = false;
} }
if (event.xkey.state & (1<<3) ) { if (event.xkey.state & (1<<3) ) {
//EWOL_DEBUG(" Special Key : Alt"); //EWOL_DEBUG(" Special Key : Alt");
guiKeyBoardMode_Alt = true; guiKeyBoardMode.alt = true;
} else { } else {
guiKeyBoardMode_Alt = false; guiKeyBoardMode.alt = false;
} }
if (event.xkey.state & (1<<4) ) { if (event.xkey.state & (1<<4) ) {
//EWOL_DEBUG(" Special Key : VER_num"); //EWOL_DEBUG(" Special Key : VER_num");
guiKeyBoardMode_VerNum = true; guiKeyBoardMode.verNum = true;
} else { } else {
guiKeyBoardMode_VerNum = false; guiKeyBoardMode.verNum = false;
} }
if (event.xkey.state & (1<<5) ) { if (event.xkey.state & (1<<5) ) {
EWOL_DEBUG(" Special Key : MOD"); EWOL_DEBUG(" Special Key : MOD");
} }
if (event.xkey.state & (1<<6) ) { if (event.xkey.state & (1<<6) ) {
//EWOL_DEBUG(" Special Key : META"); //EWOL_DEBUG(" Special Key : META");
guiKeyBoardMode_Meta = true; guiKeyBoardMode.meta = true;
} else { } else {
guiKeyBoardMode_Meta = false; guiKeyBoardMode.meta = false;
} }
if (event.xkey.state & (1<<7) ) { if (event.xkey.state & (1<<7) ) {
//EWOL_DEBUG(" Special Key : ALT_GR"); //EWOL_DEBUG(" Special Key : ALT_GR");
guiKeyBoardMode_AltGr = true; guiKeyBoardMode.altGr = true;
} else { } else {
guiKeyBoardMode_AltGr = false; guiKeyBoardMode.altGr = false;
} }
bool find = true; bool find = true;
ewol::eventKbMoveType_te keyInput; ewol::eventKbMoveType_te keyInput;
@ -543,10 +536,10 @@ void X11_Run(void)
case 118: case 118:
keyInput = ewol::EVENT_KB_MOVE_TYPE_INSERT; keyInput = ewol::EVENT_KB_MOVE_TYPE_INSERT;
if(event.type == KeyRelease) { if(event.type == KeyRelease) {
if (true == guiKeyBoardMode_Insert) { if (true == guiKeyBoardMode.insert) {
guiKeyBoardMode_Insert = false; guiKeyBoardMode.insert = false;
} else { } else {
guiKeyBoardMode_Insert = true; guiKeyBoardMode.insert = true;
} }
} }
break; break;
@ -577,19 +570,31 @@ void X11_Run(void)
case 91: // Suppr on keypad case 91: // Suppr on keypad
find = false; find = false;
{ {
eventKeyboardKey_ts specialEvent;
specialEvent.special = guiKeyBoardMode;
specialEvent.myChar = 0x0000007F;
if(event.type == KeyPress) { if(event.type == KeyPress) {
EWOL_ThreadKeyboardEvent(true, 0x0000007F); specialEvent.isDown = true;
} else { } else {
EWOL_ThreadKeyboardEvent(false, 0x0000007F); specialEvent.isDown = false;
} }
EWOL_ThreadKeyboardEvent(specialEvent);
} }
default: default:
find = false; find = false;
{ {
char buf[11]; char buf[11];
EWOL_DEBUG("Keycode: " << event.xkey.keycode);
// change keystate for simple reson of the ctrl error...
int32_t keyStateSave = event.xkey.state;
if (event.xkey.state & (1<<2) ) {
event.xkey.state = event.xkey.state & 0xFFFFFFFB;
}
KeySym keysym; KeySym keysym;
XComposeStatus status; XComposeStatus status;
int count = XLookupString(&event.xkey, buf, 10, &keysym, &status); int count = XLookupString(&event.xkey, buf, 10, &keysym, &status);
// retreave real keystate
event.xkey.state = keyStateSave;
buf[count] = '\0'; buf[count] = '\0';
// Replace \r error ... // Replace \r error ...
if (buf[0] == '\r') { if (buf[0] == '\r') {
@ -598,15 +603,16 @@ void X11_Run(void)
} }
if (count>0) { if (count>0) {
// transform iun unicode // transform iun unicode
uniChar_t unicodeValue; eventKeyboardKey_ts specialEvent;
//unicode::convertUtf8ToUnicode(buf, unicodeValue); specialEvent.special = guiKeyBoardMode;
unicode::convertIsoToUnicode(unicode::EDN_CHARSET_ISO_8859_15, buf[0], unicodeValue); unicode::convertIsoToUnicode(unicode::EDN_CHARSET_ISO_8859_15, buf[0], specialEvent.myChar);
//EWOL_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << unicodeValue); //EWOL_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << unicodeValue);
if(event.type == KeyPress) { if(event.type == KeyPress) {
EWOL_ThreadKeyboardEvent(true, unicodeValue); specialEvent.isDown = true;
} else { } else {
EWOL_ThreadKeyboardEvent(false, unicodeValue); specialEvent.isDown = false;
} }
EWOL_ThreadKeyboardEvent(specialEvent);
} else { } else {
EWOL_WARNING("Unknow event Key : " << event.xkey.keycode); EWOL_WARNING("Unknow event Key : " << event.xkey.keycode);
} }
@ -615,11 +621,15 @@ void X11_Run(void)
} }
if (true == find) { if (true == find) {
EWOL_DEBUG("eventKey Move type : " << GetCharTypeMoveEvent(keyInput) ); EWOL_DEBUG("eventKey Move type : " << GetCharTypeMoveEvent(keyInput) );
eventKeyboardMove_ts specialEvent;
specialEvent.special = guiKeyBoardMode;
if(event.type == KeyPress) { if(event.type == KeyPress) {
EWOL_ThreadKeyboardEventMove(true, keyInput); specialEvent.isDown = true;
} else { } else {
EWOL_ThreadKeyboardEventMove(false, keyInput); specialEvent.isDown = false;
} }
specialEvent.move = keyInput;
EWOL_ThreadKeyboardEventMove(specialEvent);
} }
break; break;
} }

View File

@ -56,8 +56,8 @@ namespace ewol {
bool IsSetVerNum(void); bool IsSetVerNum(void);
bool IsSetInsert(void); bool IsSetInsert(void);
namespace shortCut { namespace shortCut {
void Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString& data); void Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString data);
void Add(char * descriptiveString, const char * generateEventId, etk::UString& data); void Add(const char * descriptiveString, const char * generateEventId, etk::UString data);
}; };
int32_t GetCurrentWidth(void); int32_t GetCurrentWidth(void);

View File

@ -93,7 +93,7 @@ void ewol::List::OnRegenerateDisplay(void)
//uint32_t nbColomn = GetNuberOfColomn(); //uint32_t nbColomn = GetNuberOfColomn();
uint32_t nbRaw = GetNuberOfRaw(); int32_t nbRaw = GetNuberOfRaw();
// For the scrooling windows // For the scrooling windows
m_maxSize.x = m_size.x; m_maxSize.x = m_size.x;
m_maxSize.y = (minHeight + 2*m_paddingSizeY) * nbRaw; m_maxSize.y = (minHeight + 2*m_paddingSizeY) * nbRaw;
@ -128,7 +128,7 @@ void ewol::List::OnRegenerateDisplay(void)
drawClipping.w = m_size.x - (2*m_paddingSizeX); drawClipping.w = m_size.x - (2*m_paddingSizeX);
drawClipping.h = m_size.y; drawClipping.h = m_size.y;
for(uint32_t iii=startRaw; iii<nbRaw && iii<(startRaw+displayableRaw); iii++) { for(int32_t iii=startRaw; iii<nbRaw && iii<(startRaw+displayableRaw); iii++) {
etk::UString myTextToWrite; etk::UString myTextToWrite;
color_ts fg; color_ts fg;
color_ts bg; color_ts bg;