diff --git a/uppsrc/CtrlLib/DropChoice.cpp b/uppsrc/CtrlLib/DropChoice.cpp index b5adaac27..ef52109ad 100644 --- a/uppsrc/CtrlLib/DropChoice.cpp +++ b/uppsrc/CtrlLib/DropChoice.cpp @@ -13,6 +13,7 @@ DropChoice::DropChoice() { dropwidth = 0; appending = false; updownkeys = true; + rodrop = false; } void DropChoice::EnableDrop(bool b) @@ -26,7 +27,7 @@ void DropChoice::PseudoPush() } void DropChoice::Drop() { - if(!owner || owner->IsReadOnly() || list.GetCount() == 0 && !WhenDrop) return; + if(!owner || owner->IsReadOnly() && !rodrop || list.GetCount() == 0 && !WhenDrop) return; WhenDrop(); if(dropfocus) owner->SetWantFocus(); @@ -36,12 +37,12 @@ void DropChoice::Drop() { } void DropChoice::Select() { - if(!owner || owner->IsReadOnly()) return; + if(!owner || owner->IsReadOnly() && !rodrop) return; WhenSelect(); } Value DropChoice::Get() const { - if(!owner || owner->IsReadOnly()) return Value(); + if(!owner || owner->IsReadOnly() && !rodrop) return Value(); int c = list.GetCursor(); if(c < 0) return Value(); return list.Get(c, 0); @@ -49,7 +50,7 @@ Value DropChoice::Get() const { int DropChoice::GetIndex() const { - if(!owner || owner->IsReadOnly()) return -1; + if(!owner || owner->IsReadOnly() && !rodrop) return -1; return list.GetCursor(); } diff --git a/uppsrc/CtrlLib/DropChoice.h b/uppsrc/CtrlLib/DropChoice.h index faf6eea27..0e7eb46fb 100644 --- a/uppsrc/CtrlLib/DropChoice.h +++ b/uppsrc/CtrlLib/DropChoice.h @@ -161,6 +161,7 @@ protected: bool dropfocus; bool always_drop; bool updownkeys; + bool rodrop; void Select(); void Drop(); @@ -200,6 +201,7 @@ public: DropChoice& SetDropLines(int n) { list.SetDropLines(n); return *this; } DropChoice& Appending() { appending = true; return *this; } DropChoice& AlwaysDrop(bool e = true); + DropChoice& RdOnlyDrop(bool e = true) { rodrop = e; return *this; } DropChoice& NoDropFocus() { dropfocus = false; return *this; } DropChoice& DropWidth(int w) { dropwidth = w; return *this; } @@ -264,6 +266,7 @@ public: WithDropChoice& SetDisplay(const Display& d, int lcy) { select.SetDisplay(d, lcy); return *this; } WithDropChoice& SetConvert(const Convert& d) { select.SetConvert(d); return *this; } WithDropChoice& AlwaysDrop(bool b = true) { select.AlwaysDrop(b); return *this; } + WithDropChoice& RdOnlyDrop(bool b = true) { select.RdOnlyDrop(b); return *this; } WithDropChoice& WithWheel(bool b = true) { withwheel = b; return *this; } WithDropChoice& NoWithWheel() { return WithWheel(false); } WithDropChoice& DropWidth(int w) { select.DropWidth(w); return *this; } diff --git a/uppsrc/CtrlLib/src.tpp/WithDropChoice$en-us.tpp b/uppsrc/CtrlLib/src.tpp/WithDropChoice$en-us.tpp index 59f93b74b..7405250f7 100644 --- a/uppsrc/CtrlLib/src.tpp/WithDropChoice$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/WithDropChoice$en-us.tpp @@ -127,6 +127,11 @@ hoice][@(0.0.255) `&]_[* SetDisplay]([@(0.0.255) const]_[_^Display^ Display][@(0 (client code can fill it using WhenDrop callback).&] [s3; &] [s4; &] +[s5;:WithDropChoice`:`:RdOnlyDrop`(bool`): [_^WithDropChoice^ WithDropChoice][@(0.0.255) `& +]_[* RdOnlyDrop]([@(0.0.255) bool]_[*@3 b]_`=_[@(0.0.255) true])&] +[s2;%% If active, allows changing value even by drop even if ReadOnly.&] +[s3;%% &] +[s4; &] [s5;:WithDropChoice`:`:WithWheel`(bool`): [_^WithDropChoice^ WithDropChoice][@(0.0.255) `& ]_[* WithWheel]([@(0.0.255) bool]_[*@3 b]_`=_[@(0.0.255) true])&] [s2;%% Widget reacts to mousewheel. This is active by default.&]