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 » GridCtrl - grid problem when i set focus
GridCtrl - grid problem when i set focus [message #56313] Fri, 19 February 2021 22:29 Go to next message
BetoValle is currently offline  BetoValle
Messages: 203
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
Hi,

When i load GridCtrl the focus now show as espected
(at the beginning of the grid with blue highlighted line)
Why? (see *** )

#include <CtrlLib/CtrlLib.h>
#include <GridCtrl/GridCtrl.h>

using namespace Upp;

class PopUpWin : public GridCtrl
{
	private:
		bool poppedUp_;

		bool Key ( dword key, int count )
		{
			if ( GetKeyDesc ( key ) == "Esc" )
			{
				fecha();
			}

			return false;
		}

	public:
		PopUpWin() : poppedUp_ ( false ) { }

		void SetPoppedUp ( bool yesNo )
		{
			poppedUp_ = yesNo;
		}

		bool IsPoppedUp() const
		{
			return poppedUp_;
		}

		void fecha()
		{
			Clear ( true );
			Close();
			poppedUp_ = false;
		}
		
		void gridProp(){
			AddColumn ( "coluna1" );
			AddColumn ( "coluna2" );
			AddColumn ( "coluna3" );
			Add ( "1", "1", "1" );
			Add ( "2", "2", "2" );
			Add ( "3", "3", "3" );
			Add ( "4", "4", "4" );
			
			MultiSorting ( true );
			Searching();
			find.NullText("busca");
			SetToolBar ( BarCtrl::BAR_BOTTOM );
            			
			MultiSelect ( true );
			Clipboard ( true );
			ExtraPaste ( false );
			FixedPaste ( false );
			paste_allowed = false;
			cut_allowed = false;
			Indicator ( true );
			Navigating ( true );			
		}

		void Config ( Rect r, Ctrl* w, EditField* cpo  )
		{
			LeftPos ( (fround ( r.right ) / 2 ) + 200, 300 ).TopPos ( fround ( r.bottom ) / 2 , 150 );

                        gridProp();
			
			WhenLeftDouble = [=]
			{
	                   cpo->SetText( Get( GetCursor(),0).ToString() );
                           cpo->SetFocus();
                           fecha();	
			};

			PopUp
			(
				w,	// Ctrl*	owner		= NULL
				true,	// bool		savebits	= true
				true,	// bool		activate	= true
				true,	// bool		dropshadow	= false
				false	// bool		topmost		= false
			);

		}

};

class MainWin : public TopWindow
{
	private:
		//close grid
		void LeftDown ( Point p, dword keyFlags )
		{
			if ( Single<PopUpWin>().IsPoppedUp() )
				Single<PopUpWin>().fecha();
		}

	public:
		typedef MainWin CLASSNAME;
		Button button;
		EditField fld;
		
		void click()
		{
            
			if ( Single<PopUpWin>().IsPoppedUp() )
				return;

			Single<PopUpWin>().SetPoppedUp ( true );

			Single<PopUpWin>().Config ( Size(800,600) , this,&fld);
			
			// *** these 2 lines below don't work!
			// *** should they work ?
			Single<PopUpWin>().SetFocus();
			Single<PopUpWin>().Begin();
			
       }

		MainWin()
		{

			button <<= THISBACK ( click );
			button.SetLabel ( "show grid" );
			Add ( fld.VCenterPos ( 23 ).HCenterPos ( 200 ) );
            
                        Add(button.LeftPosZ(304, 100).TopPosZ(304, 23));
		}

};

GUI_APP_MAIN
{
	SetLanguage ( "pt-br" );
	MainWin mainWin;
	mainWin.SetRect ( 0, 0, 800, 600 );

	mainWin.Sizeable ( true );
	mainWin.Run();
}



Thanks

Re: GridCtrl - grid problem when i set focus [message #56314 is a reply to message #56313] Fri, 19 February 2021 22:33 Go to previous messageGo to next message
BetoValle is currently offline  BetoValle
Messages: 203
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member

correction in time: "When i load GridCtrl the focus NOT show as expected"
Re: GridCtrl - grid problem when i set focus [message #56315 is a reply to message #56314] Sat, 20 February 2021 04:06 Go to previous message
BetoValle is currently offline  BetoValle
Messages: 203
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
Hi

I found the solution:


                         // *** these 2 lines below work!
			Single<PopUpWin>().DoGoBegin();    // or DoGoEnd() to last register
			Single<PopUpWin>().SetFocus();


Thanks
Previous Topic: Insert Ctrl editors in a single row of ArrayCtrl
Next Topic: GridCtrl MultiSelect bug
Goto Forum:
  


Current Time: Sun Jun 16 20:05:15 CEST 2024

Total time taken to generate the page: 0.02591 seconds