mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-20 01:08:15 +01:00
[apps/code] Fix Key selector in auto completion
Scenario: Go in the Python editor and type "from ion import *",
then type "K" and see what happens.
This fix UpsilonNumworks#198
This commit is contained in:
@@ -9,42 +9,49 @@ extern "C" {
|
||||
extern "C" const mp_rom_map_elem_t modion_module_globals_table[52];
|
||||
|
||||
namespace Code {
|
||||
toolboxIonKeys::toolboxIonKeys() :
|
||||
ToolboxIonKeys::ToolboxIonKeys() :
|
||||
ViewController(nullptr),
|
||||
m_view()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
bool toolboxIonKeys::handleEvent(Ion::Events::Event e) {
|
||||
Ion::Keyboard::State state = Ion::Keyboard::scan();
|
||||
for(uint16_t i = 0; i < sizeof(modion_module_globals_table)/sizeof(_mp_rom_map_elem_t); i++){
|
||||
_mp_rom_map_elem_t element = modion_module_globals_table[i];
|
||||
if(mp_obj_is_small_int(element.value)){
|
||||
int key = mp_obj_get_int(element.value);
|
||||
if(state.keyDown(static_cast<Ion::Keyboard::Key>(key))){
|
||||
m_sender->handleEventWithText(qstr_str(MP_OBJ_QSTR_VALUE(element.key)), true);
|
||||
}
|
||||
bool ToolboxIonKeys::handleEvent(Ion::Events::Event e) {
|
||||
// FIXME: Use event data to get the pressed key and fix the EXE key.
|
||||
Ion::Keyboard::State state = Ion::Keyboard::scan();
|
||||
for (uint16_t i = 0; i < sizeof(modion_module_globals_table) / sizeof(_mp_rom_map_elem_t); i++) {
|
||||
_mp_rom_map_elem_t element = modion_module_globals_table[i];
|
||||
if (mp_obj_is_small_int(element.value)) {
|
||||
int key = mp_obj_get_int(element.value);
|
||||
if (state.keyDown(static_cast<Ion::Keyboard::Key>(key))) {
|
||||
m_sender->handleEventWithText(qstr_str(MP_OBJ_QSTR_VALUE(element.key)), true);
|
||||
}
|
||||
}
|
||||
Container::activeApp()->dismissModalViewController();
|
||||
AppsContainer::sharedAppsContainer()->redrawWindow();
|
||||
return true;
|
||||
}
|
||||
Container::activeApp()->dismissModalViewController();
|
||||
AppsContainer::sharedAppsContainer()->redrawWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
toolboxIonKeys::toolboxIonView::toolboxIonView():
|
||||
View()
|
||||
{
|
||||
}
|
||||
ToolboxIonKeys::toolboxIonView::toolboxIonView() :
|
||||
View()
|
||||
{
|
||||
}
|
||||
|
||||
void toolboxIonKeys::toolboxIonView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(rect, Palette::WallScreen);
|
||||
ctx->strokeRect(rect, Palette::ListCellBorder);
|
||||
ctx->drawString(I18n::translate(I18n::Message::PressAKey),KDPoint(rect.left()+80, rect.top()+20),KDFont::LargeFont,Palette::PrimaryText,Palette::WallScreen);
|
||||
|
||||
}
|
||||
void ToolboxIonKeys::toolboxIonView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(rect, Palette::WallScreen);
|
||||
ctx->strokeRect(rect, Palette::ListCellBorder);
|
||||
KDSize fontSize = KDFont::LargeFont->glyphSize();
|
||||
const char * message = I18n::translate(I18n::Message::PressAKey);
|
||||
// Get the starting position of the text to center it.
|
||||
KDPoint textPosition = KDPoint(rect.size().width() / 2 - strlen(message) * fontSize.width() / 2,
|
||||
rect.size().height() / 2 - fontSize.height() / 2);
|
||||
|
||||
View * toolboxIonKeys::view(){
|
||||
return &m_view;
|
||||
}
|
||||
ctx->drawString(message, textPosition, KDFont::LargeFont, Palette::PrimaryText, Palette::WallScreen);
|
||||
|
||||
}
|
||||
|
||||
View * ToolboxIonKeys::view() {
|
||||
return &m_view;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user