Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » AcceptRow broken when SetCtrl is used
AcceptRow broken when SetCtrl is used [message #16744] |
Wed, 09 July 2008 15:41 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
ArrayCtrl::AcceptRow doesn't check any child ctrls set with SetCtrl() when accepting rows, which in turn can lead to dialogs being accepted with invalid data (a big problem!). A quick test case:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
GUI_APP_MAIN
{
TopWindow wnd;
ArrayCtrl ctrl;
Button ok;
Button cancel;
Array<EditInt> edit;
Rect r = Rect(0, 0, 200, 300);
wnd.Sizeable().SetMinSize(r.GetSize());
wnd.SetRect(r + GetScreenSize() / 2 - r.GetSize()/2);
wnd.Add(ctrl.HSizePos().VSizePos(0, 28));
wnd.Add(ok.SetLabel("OK").RightPos(88, 80).BottomPos(4, 22));
wnd.Add(cancel.SetLabel("Cancel").RightPos(4, 80).BottomPos(4, 22));
wnd.Acceptor(ok, IDOK);
wnd.Rejector(cancel, IDCANCEL);
edit.SetCount(20);
ctrl.AddColumn("EditInts (0-1)");
ctrl.SetCount(20);
for (int i = 0; i < edit.GetCount(); i++) {
edit[i].Min(0).Max(1) <<= 1;
ctrl.SetCtrl(i, 0, edit[i]);
}
wnd.Execute();
}
Just type 2 into one of the rows and then change row, this should trigger an Exclamation but doesn't. You will be also able to 'OK' the form with the invalid data still in the ctrl.
I've attempted to fix this myself but just adding a check in AcceptRow causes a stack overflow due to focus changes when an Exclamation is shown by the child's Accept() function, so I'll leave it to someone with better knowledge of ArrayCtrl.
I'd settle for just checking all the ctrls in the ArrayCtrl's Accept function if fixing AcceptRow is impossible/very difficult.
Cheers.
[Updated on: Wed, 09 July 2008 16:21] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Tue May 14 15:58:40 CEST 2024
Total time taken to generate the page: 0.02322 seconds
|