Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » ArrayCtrl: Edit doesn't like Option
ArrayCtrl: Edit doesn't like Option [message #29516] Mon, 25 October 2010 17:15 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
Let me start by saying that this is the first time I used ArrayCtrl. I tried it before, but it seemed overkill and I have been using ColumnList up until now and it served my needs quite well.

But now I need it and I'm having a problem with it. I have some columns with Edit(someEditor). Like EditString. Works fine. But when adding Ctrls<Option> to some other columns, Edit no longer works for the previous ones. Probably related to the way the embedded Option gets focused. It had huge troubles with Option and OptionTree and was wondering if there is a solution for this without having to go through all that trouble again.
Re: ArrayCtrl: Edit doesn't like Option [message #29522 is a reply to message #29516] Tue, 26 October 2010 10:03 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1391
Registered: September 2007
Senior Contributor
Problem solved!

Thank you very much, SenderGhost!

The CreateOption method is key from this post: link

[Updated on: Tue, 26 October 2010 10:04]

Report message to a moderator

Re: ArrayCtrl: Edit doesn't like Option [message #30071 is a reply to message #29522] Tue, 07 December 2010 09:37 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
i've got another problem, which is similar to yours, so i just reuse your thread Smile

problem: ArrayCtrl has got Option's as Editors, and some EditInt's.. everytime changes are made, i need to forward them in a custim action..(OnAction)


ArrayCtrl ac;
...
Ctrl* p = new Option();
p->WhenAction = THISBACK(OnAction);
SetCtrl(k, 1, p);
++k;
...
p = new EditInt();
p->WhenAction = THISBACK(OnAction);
ac.SetCtrl(k, 1, p);
...
void MyClass::OnAction()
{
   DoWork(ac.Get(0), ac.Get(1));
}


this works fine for EditInt, because the cursor is set properly, when EditInt is 'selected' to be edited, because EditField has SetFocus somewhere in it.. with Option, no cursor is set, when i cklick it, so the OnAction fails with an ASSERT.

when i manually select the row, clicking on the right remaining spot, that belongs to arrayctrl, and then, on the Option, it works..

any help, how to make Option be Focus aware? i dont like to mess with the upp code.. maybe i'm doing sth wrong ..


[Updated on: Tue, 07 December 2010 09:59]

Report message to a moderator

Re: ArrayCtrl: Edit doesn't like Option [message #30072 is a reply to message #30071] Tue, 07 December 2010 11:08 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

You could use GridCtrl Wink it moves cursor always. However if you prefer ArrayCtrl just make your own control that derives from ArrayCtrl and override ChildGotFocus() method. In this method place the cursor in the correct location (row). This method is called before control's action callback so everything should work.
Re: ArrayCtrl: Edit doesn't like Option [message #30074 is a reply to message #30072] Tue, 07 December 2010 11:22 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
as far as i could see, GetChilfFocus is used in ArrayCtrl as well, the problem is, that Option does not aquire focus Smile, there is no SetFocus() in Pusher..
Re: ArrayCtrl: Edit doesn't like Option [message #30075 is a reply to message #30074] Tue, 07 December 2010 12:37 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

Sorry. I made a mistake Smile I meant overriding void ChildMouseEvent(Ctrl *child, int event, Point p, int zdelta, dword keyflags). I use this method in GridCtrl to move cursor if embedded control is clicked and it works perfectly.
Re: ArrayCtrl: Edit doesn't like Option [message #30076 is a reply to message #30075] Tue, 07 December 2010 12:39 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
thanks a lot. i'll give it a try..

wouldn't it be better to also implement this for ArrayCtrl?
Re: ArrayCtrl: Edit doesn't like Option [message #30078 is a reply to message #30076] Tue, 07 December 2010 13:14 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

kohait00 wrote on Tue, 07 December 2010 06:39


wouldn't it be better to also implement this for ArrayCtrl?

Well, moving cursor is IMO the correct way to deal with embedded controls and most of grids works this way otherwise you break consistency in control's callbacks. On the other hand Mirek has different opinion here. If I remember correctly he wanted to be able to type the text in one row without loosing focus by clicking option/button/droplist in another row or the same row but in another column. Cursor is moved only if you click on edit control. Actually I don't know in which scenario this can be useful Smile.
Re: ArrayCtrl: Edit doesn't like Option [message #30080 is a reply to message #30078] Tue, 07 December 2010 14:03 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
i think the same..
clicking on a Option switch means changing a data set in a row, which then needs to be updated to database, i.e..
so maybe he still can be convinced of it.

meanwhile, i might try the GridCtrl, if it offers the same possibilities..
Re: ArrayCtrl: Edit doesn't like Option [message #30090 is a reply to message #30080] Wed, 08 December 2010 09:51 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
do you have any code already as a fix for ArrayCtrl?
i mean a ChildMouseEvent(Ctrl *child, int event, Point p, int zdelta, dword keyflags) based one, just to have a base for mirek to talk about

EDIT:
ok, i stiched an add to ArrayCtrl, in a similar manner like you did in GridCtrl, now it's up on Mirek to decide if this goes well..thankyou for yor support

ArrayCtrl.h:38
	virtual void ChildMouseEvent(Ctrl *child, int event, Point p, int zdelta, dword keyflags);


ArrayCtrl.cpp:713
void ArrayCtrl::ChildMouseEvent(Ctrl *child, int event, Point p, int zdelta, dword keyflags)
{
	if(child != GetFocusCtrl())
	{
		if(event == LEFTDOWN || event == RIGHTDOWN || event == MOUSEWHEEL)
		{
			Point p = FindCellCtrl(child);
			if(!IsNull(p))
			{
				if(nocursor)
					ScrollInto(p.y);
				else
					SetCursor(p.y);
			}
		}
	}
	Ctrl::ChildMouseEvent(child, event, p, zdelta, keyflags);
}

[Updated on: Wed, 08 December 2010 11:19]

Report message to a moderator

Re: ArrayCtrl: Edit doesn't like Option [message #30103 is a reply to message #30090] Thu, 09 December 2010 09:31 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
there is a
Pusher::ClickFocus();

function, that enables Option and others to have SetFocus functionality, so ArrayCtrl changes Cursor right.

but the general question as stated above remains..
Re: ArrayCtrl: Edit doesn't like Option [message #30354 is a reply to message #30103] Sun, 26 December 2010 01:12 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12024
Registered: November 2005
Ultimate Member
kohait00 wrote on Thu, 09 December 2010 03:31

there is a
Pusher::ClickFocus();

function, that enables Option and others to have SetFocus functionality, so ArrayCtrl changes Cursor right.

but the general question as stated above remains..


IMO, you might not want to move focus in ArrayCtrl for the same reason you might not want to move it in general dialog. (Well, as unodgs stated, it always seemed illogical to me. I really dislike those focus rectangles on buttons, options and switches Smile

Also, note there is even a global setting, call Ctrl::ClickFocus(true) and you are done...

Mirek
Re: ArrayCtrl: Edit doesn't like Option [message #30356 is a reply to message #30354] Sun, 26 December 2010 09:46 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
thanks, thats a help, bringing together both worlds Smile
Re: ArrayCtrl: Edit doesn't like Option [message #34970 is a reply to message #29522] Thu, 22 December 2011 02:43 Go to previous message
Sender Ghost is currently offline  Sender Ghost
Messages: 288
Registered: November 2008
Experienced Member
Hello.

While reading uppdev sources, I found ArrayOption example.

I think, it could be used here, like follows:
Toggle Spoiler

index.php?t=getfile&id=3596&private=0

[Updated on: Fri, 23 December 2011 21:08]

Report message to a moderator

Previous Topic: ArrayCtrl Write To Freed Memory Detected
Next Topic: Not able to remove Columns in Grid.
Goto Forum:
  


Current Time: Mon Sep 23 13:56:57 CEST 2019

Total time taken to generate the page: 0.01149 seconds