mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Some more keyboard related tweaks.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@661 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -79,17 +79,23 @@ void DataEditor::selectFirst() {
|
||||
selectByTabPos(0);
|
||||
}
|
||||
bool DataEditor::selectNext() {
|
||||
return selectByTabPos(currentTabPos() + 1);
|
||||
return selectByTabPos(currentTabPos() + 1, true);
|
||||
}
|
||||
bool DataEditor::selectPrevious() {
|
||||
return selectByTabPos(currentTabPos() - 1);
|
||||
return selectByTabPos(currentTabPos() - 1, false);
|
||||
}
|
||||
|
||||
bool DataEditor::selectByTabPos(int tab_pos) {
|
||||
if (tab_pos >= 0 && (size_t)tab_pos < by_tab_index.size()) {
|
||||
select(by_tab_index[tab_pos]);
|
||||
return true;
|
||||
} else if (!by_tab_index.empty()) {
|
||||
bool DataEditor::selectByTabPos(int tab_pos, bool forward) {
|
||||
while (tab_pos >= 0 && (size_t)tab_pos < by_tab_index.size()) {
|
||||
ValueViewer* v = by_tab_index[tab_pos];
|
||||
if (v->getField()->editable) {
|
||||
select(v);
|
||||
return true;
|
||||
}
|
||||
// not enabled, maybe the next one?
|
||||
tab_pos += forward ? 1 : -1;
|
||||
}
|
||||
if (!by_tab_index.empty()) {
|
||||
// also select something! so when we regain focus the selected editor makes sense
|
||||
if (tab_pos < 0) select(by_tab_index.back());
|
||||
else select(by_tab_index.front());
|
||||
@@ -235,7 +241,7 @@ void DataEditor::onMotion(wxMouseEvent& ev) {
|
||||
if (!HasCapture()) {
|
||||
// find editor under mouse
|
||||
ValueViewer* new_hovered_viewer = nullptr;
|
||||
FOR_EACH_EDITOR_REVERSE { // find high z index fields first
|
||||
FOR_EACH_REVERSE(v,viewers) { // find high z index fields first
|
||||
if (v->containsPoint(pos) && v->getField()->editable) {
|
||||
new_hovered_viewer = v.get();
|
||||
break;
|
||||
@@ -305,8 +311,6 @@ void DataEditor::selectFieldNoEvents(const RealPoint& p) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
//% current_viewer = nullptr;
|
||||
//% current_editor = nullptr;
|
||||
}
|
||||
|
||||
RealPoint DataEditor::mousePoint(const wxMouseEvent& ev) {
|
||||
|
||||
@@ -126,7 +126,7 @@ class DataEditor : public CardViewer {
|
||||
void createTabIndex();
|
||||
/// Select the field with the given position in the by_tab_index list
|
||||
/** Returns success */
|
||||
bool selectByTabPos(int tab_pos);
|
||||
bool selectByTabPos(int tab_pos, bool forward = true);
|
||||
/// Find the tab pos of the current viewer, returns -1 if not found
|
||||
int currentTabPos() const;
|
||||
};
|
||||
|
||||
@@ -18,7 +18,6 @@ DECLARE_TYPEOF_COLLECTION(ValueViewerP);
|
||||
|
||||
TextCtrl::TextCtrl(Window* parent, int id, bool multi_line, long style)
|
||||
: DataEditor(parent, id, style)
|
||||
, value(nullptr)
|
||||
, multi_line(multi_line)
|
||||
{}
|
||||
TextCtrl::~TextCtrl() {}
|
||||
@@ -36,6 +35,12 @@ void TextCtrl::draw(DC& dc) {
|
||||
}
|
||||
}
|
||||
|
||||
bool TextCtrl::AcceptsFocus() const {
|
||||
return wxControl::AcceptsFocus() &&
|
||||
!viewers.empty() &&
|
||||
static_cast<FakeTextValue&>(*viewers.front()->getValue()).editable;
|
||||
}
|
||||
|
||||
|
||||
TextStyle& TextCtrl::getStyle() {
|
||||
assert(!viewers.empty());
|
||||
|
||||
@@ -55,6 +55,8 @@ class TextCtrl : public DataEditor {
|
||||
|
||||
virtual void draw(DC& dc);
|
||||
|
||||
virtual bool AcceptsFocus() const;
|
||||
|
||||
virtual void onChangeSet();
|
||||
|
||||
protected:
|
||||
@@ -62,7 +64,6 @@ class TextCtrl : public DataEditor {
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
String* value; ///< Value to edit
|
||||
bool multi_line; ///< Multi line text control?
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
Reference in New Issue
Block a user