|
|
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » ArrayCtrl cell consisting of edit and helper button
ArrayCtrl cell consisting of edit and helper button [message #2611] |
Wed, 19 April 2006 04:13 |
kevinle10@gmail.com
Messages: 25 Registered: April 2006
|
Promising Member |
|
|
What would be the easiest way to have an ArrayCtrl with cells whose each of them consists of an edit field and a helper button (button caption is like "..."). An example can be seen in VC++ 2005 by going to Tools->Options->VC++ Diretories and look at the list on the right hand side.
Basically, the ArrayCtrl supports inline editing, but each cell at the time of being edited also shows a small button at the right edge.
Thanks
|
|
|
|
|
|
Re: ArrayCtrl cell consisting of edit and helper button [message #2621 is a reply to message #2620] |
Wed, 19 April 2006 07:53 |
|
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
ok, you can try this and tell if it's what you expected.
#include <CtrlLib/CtrlLib.h>
class Ctrl2 : public ParentCtrl {
EditField edit;
Button button;
public:
typedef Ctrl2 CLASSNAME;
Ctrl2();
~Ctrl2() {;}
};
Ctrl2::Ctrl2()
{
edit.SetRect(0,0,50,15); //one problem are sizes >15...
button.SetRect(55,0,85,15);
button.SetLabel("Help!!!");
Add(edit);
Add(button);
}
void Extra2(One<Ctrl>& ctrl)
{
ctrl.Create<Ctrl2>();
}
GUI_APP_MAIN
{
TopWindow w;
ArrayCtrl arr;
arr.AddColumn("col1",2);
arr.AddColumn("col2",5).Ctrls(Extra2);
arr.SetLineCy(20);
arr.Add("aaa");
arr.Add("bbb");
arr.SizePos();
w.Add(arr);
w.Run();
}
|
|
|
|
|
|
|
Re: ArrayCtrl cell consisting of edit and helper button [message #3074 is a reply to message #2633] |
Sat, 06 May 2006 01:31 |
|
forlano
Messages: 1202 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
luzr wrote on Wed, 19 April 2006 14:31 | BTW, consider using layout....
|
Hello,
I've modified a bit the Aris' example above using the layout as Mirek suggested to create an embedded two-control made by an editint followed by a label. What is entered in the edit is immediately replicated in the label. Here it is:
#include <CtrlLib/CtrlLib.h>
#define LAYOUTFILE <edithelp/a.lay>
#include <CtrlCore/lay.h>
//--------------------- begin class -----------------
class EditLabel : public WithEditLabel<TopWindow> {
public:
typedef EditLabel CLASSNAME;
void WriteLabel();
EditLabel();
};
void EditLabel::WriteLabel()
{ lbl.SetLabel( AsString(~edit) );
//SetFocus();
}
EditLabel::EditLabel()
{ CtrlLayout(*this, "");
edit <<= THISBACK(WriteLabel);
}
void Extra2(One<Ctrl>& ctrl)
{ ctrl.Create<EditLabel>();
}
//--------------------- end class -------------------
GUI_APP_MAIN
{
TopWindow w;
ArrayCtrl arr;
arr.AddColumn("col1",20);
arr.AddColumn("col2",20).Ctrls(Extra2);
arr.SetLineCy(20);
arr.Add("aaa");
arr.Add("bbb");
arr.SizePos();
w.Add(arr);
w.Run();
}
LAYOUT(EditLabel, 96, 19)
ITEM(EditInt, edit, LeftPosZ(2, 32).TopPosZ(1, 17))
ITEM(Label, lbl, SetFrame(ThinInsetFrame()).LeftPosZ(36, 60).TopPosZ(1, 17))
END_LAYOUT
Now the horintal alignement is improved drastically and there is no problem with size > 15 that can be tuned as one like.
Moreover appear the annoying problem of the cursor of the array that does not follow the click on the embedded control. To overcome it I've added
SetFocus();
connected to edit.WhenAction but then come two new unwanted side effects:
1) WhenAction was already used to pass the value to the label at the right. So while one type in the editint it continue to focus when should not be necessary (in principle).
2) Instead happens that after the first SetFocus() the cursor of the array is syncronised with the embedded control but the focus escape from editint and finish somewhere else in the row and one cannot continue the edit of the field!
Any idea to overcame the problem?
Luigi
|
|
|
|
|
|
Re: ArrayCtrl cell consisting of edit and helper button [message #3080 is a reply to message #3079] |
Sat, 06 May 2006 03:03 |
|
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
Also, try to change (with the above)
WithEditLabel<TopWindow> -> WithEditLabel<ParentCtrl>
and
CtrlLayout(*this,""); -> CtrlLayout(*this);
also:
ctrl.Create<EditLabel>().SizePos();
and this:
LAYOUT(EditLabel, 124, 32)
ITEM(EditInt, edit, LeftPosZ(12, 32).VCenterPosZ(17, 1))
ITEM(Label, lbl, SetFrame(ThinInsetFrame()).LeftPosZ(64, 56).VCenterPosZ(16, 0))
END_LAYOUT
[Updated on: Sat, 06 May 2006 03:17] Report message to a moderator
|
|
|
|
Re: ArrayCtrl cell consisting of edit and helper button [message #3086 is a reply to message #3085] |
Sat, 06 May 2006 10:44 |
|
forlano
Messages: 1202 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
forlano wrote on Sat, 06 May 2006 10:38 |
fudadmin wrote on Sat, 06 May 2006 02:58 | try this:
void EditLabel::WriteLabel()
{
lbl.SetLabel( AsString(~edit) );
SetFocus();
edit.SetFocus();
edit.SetSelection(edit.GetLength());
}
btw, why do you use a label and not a button?
|
|
Thanks!
Everything work perfectly. Your improvements automatically include a feature that I wanted: each time I pressed the TAB key the focus pass to the next editint.
I need a label to show the match result [1-0], [0-1] etc..., while in the editint I enter their short code 1, 0, and so on.
Let me ask you (this is a good moment for it) what is the difference between deriving from TopWindow and CtrlParent. It seems the second one is better for embedded widget in that it merge better with the around widget. While the first one seems more indicate for indipendent widget like dialog. Is it correct?
BTW, can you add two words for the tricky row:
edit.SetSelection(edit.GetLength());
without it I can't enter more than one char.
Luigi
[Updated on: Sun, 07 May 2006 21:07] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Thu Oct 31 23:58:56 CET 2024
Total time taken to generate the page: 0.01038 seconds
|
|
|