Tab/Enter key navigation
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
04af30b30f
commit
78d259dc59
@ -4,6 +4,8 @@
|
||||
|
||||
using namespace olc;
|
||||
|
||||
QuickGUI::TextBox*prevTextBox=nullptr;
|
||||
|
||||
// Override base class with your custom functionality
|
||||
class ChampionsLeaguePointSolver : public olc::PixelGameEngine
|
||||
{
|
||||
@ -219,21 +221,26 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine
|
||||
}
|
||||
}
|
||||
public:
|
||||
QuickGUI::TextBox*prevTextBox=nullptr;
|
||||
struct SongElement{
|
||||
SongElement(QuickGUI::Manager&manager,std::string songName,vf2d pos){
|
||||
label=new QuickGUI::Label(manager,songName,pos,{164,12});
|
||||
p1Score=new QuickGUI::TextBox(manager,"",pos+vf2d{192,0},{36,12});
|
||||
p2Score=new QuickGUI::TextBox(manager,"",pos+vf2d{192+42*1,0},{36,12});
|
||||
p3Score=new QuickGUI::TextBox(manager,"",pos+vf2d{192+42*2,0},{36,12});
|
||||
if(prevTextBox!=nullptr){
|
||||
prevTextBox->tabNext=p1Score;
|
||||
}
|
||||
p1Score->tabNext=p2Score;
|
||||
p1Score->tabPrev=prevTextBox;
|
||||
p2Score->tabNext=p3Score;
|
||||
p2Score->tabPrev=p1Score;
|
||||
prevTextBox=p3Score;
|
||||
p3Score->tabPrev=p2Score;
|
||||
}
|
||||
QuickGUI::Label*label;
|
||||
QuickGUI::TextBox*p1Score;
|
||||
QuickGUI::TextBox*p2Score;
|
||||
QuickGUI::TextBox*p3Score;
|
||||
QuickGUI::TextBox*prevP1Box;
|
||||
QuickGUI::TextBox*prevP2Box;
|
||||
QuickGUI::TextBox*prevP3Box;
|
||||
};
|
||||
QuickGUI::Manager gui;
|
||||
std::vector<SongElement>songs;
|
||||
|
Binary file not shown.
@ -601,8 +601,26 @@ namespace olc::QuickGUI
|
||||
}
|
||||
}
|
||||
|
||||
if (m_bTextEdit && pge->IsTextEntryEnabled())
|
||||
if (m_bTextEdit && pge->IsTextEntryEnabled()){
|
||||
sText = pge->TextEntryGetString();
|
||||
if((pge->GetKey(olc::Key::TAB).bPressed||pge->GetKey(olc::Key::ENTER).bPressed)&&!TextBox::bBoxClicked){
|
||||
if(pge->GetKey(olc::Key::SHIFT).bHeld){
|
||||
if(tabPrev!=nullptr){
|
||||
m_bTextEdit = false;
|
||||
pge->TextEntryEnable(true, tabPrev->sText);
|
||||
tabPrev->m_bTextEdit=true;
|
||||
TextBox::bBoxClicked=true;
|
||||
}
|
||||
}else{
|
||||
if(tabNext!=nullptr){
|
||||
m_bTextEdit = false;
|
||||
pge->TextEntryEnable(true, tabNext->sText);
|
||||
tabNext->m_bTextEdit=true;
|
||||
TextBox::bBoxClicked=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextBox::Draw(olc::PixelGameEngine* pge)
|
||||
|
@ -3664,7 +3664,7 @@ namespace olc
|
||||
else
|
||||
{
|
||||
OnTextEntryComplete(sTextEntryString);
|
||||
TextEntryEnable(false);
|
||||
//TextEntryEnable(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user