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 » SelectRow event
SelectRow event [message #5917] Wed, 25 October 2006 11:44 Go to next message
cioannou is currently offline  cioannou
Messages: 45
Registered: January 2006
Location: Greece
Member
Just started playing with Upp and I am trying to figure out how to handle a "selectrow" event in ArrayCtrl.

To start with, I would like to pop a message when the user clicks a row in ArrayCtrl and display the table name the user selected.

I already used the THISBACK for the button but I cannot understand how to catch and handle the WhenLeftClick event.

#include "MysqlDemo.h"
#include "mysql/mysql.h"


void MysqlDemo::click()
{
//	
//PromptOK("Button Pressed");
MySqlSession session;
String tables;

	// substitute your 'username' and 'password' here:
	if(!session.Connect("testuser", "", "test", "localhost")) {
		PromptOK("Can't connect with MySql\n");
		return;
	}
	Sql sql(session);
	sql.Execute("use test");
	sql.Execute("show tables");
	
	this->tableslist.AddColumn("MySql Tables", 100);
	
	while(sql.Fetch())
	{
		//Cout() << (String)sql[0] << '\n';
		tables += (String)sql[0] + '\n';
		
		this->mylist.Add((String)sql[0]);
		
		this->tableslist.Add((String)sql[0]);
		
	}
	//PromptOK(tables);
	
	sql.Execute("insert into testtbl (field1,field2) values ('UPP rocks','And looks easy too')");
	
	sql.Commit();
}

MysqlDemo::MysqlDemo()
{
	CtrlLayout(*this, "Mysql Upp Demo");
	this->strFullPath.SetData("Enter a string");
	this->strFileName.SetData("Another string");
	this->myButton <<= THISBACK(click);
}

GUI_APP_MAIN
{
	MysqlDemo().Run();
}

Re: SelectRow event [message #5918 is a reply to message #5917] Wed, 25 October 2006 12:23 Go to previous messageGo to next message
cioannou is currently offline  cioannou
Messages: 45
Registered: January 2006
Location: Greece
Member
Gotit!

tableslist.WhenSelection = THISBACK(TableSelected);

Now the strange thing is that the event is fired twice!

Any Ideas?
Re: SelectRow event [message #5928 is a reply to message #5918] Wed, 25 October 2006 14:34 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13980
Registered: November 2005
Ultimate Member
Should be fired each time selection is changed.

Frankly, ArrayCtrl callbacks are now a litle bit messy state. It is direct result of 5 years of development; each time we needed to solve some problem in our commercial code and ArrayCtrl, we have added specific callback.

I think we should definitely reinvestigate this and make most of current callbacks obsolete (but supported) and introduce some order into chaos...

Mirek
Re: SelectRow event [message #5932 is a reply to message #5928] Wed, 25 October 2006 14:47 Go to previous messageGo to next message
cioannou is currently offline  cioannou
Messages: 45
Registered: January 2006
Location: Greece
Member
luzr wrote on Wed, 25 October 2006 15:34

Should be fired each time selection is changed.

Frankly, ArrayCtrl callbacks are now a litle bit messy state. It is direct result of 5 years of development; each time we needed to solve some problem in our commercial code and ArrayCtrl, we have added specific callback.

I think we should definitely reinvestigate this and make most of current callbacks obsolete (but supported) and introduce some order into chaos...

Mirek



LOL, am I lucky or what? This is my first UPP attempt that something looks to work and I ran directly onto the strange stuff.

Laughing Laughing Laughing
Re: SelectRow event [message #5937 is a reply to message #5932] Wed, 25 October 2006 15:02 Go to previous message
mirek is currently offline  mirek
Messages: 13980
Registered: November 2005
Ultimate Member
Quote:


LOL, am I lucky or what? This is my first UPP attempt that something looks to work and I ran directly onto the strange stuff.

Laughing Laughing Laughing


Oh, not really strange. All callbacks work as defined.

You just reminded me about the problem that it would be nice to make a little cleanup there... Maybe I am in too verbose mode today Smile

Mirek
Previous Topic: WhenAddRow and WhenRemoveRow
Next Topic: horizontal scroll
Goto Forum:
  


Current Time: Wed May 15 02:16:52 CEST 2024

Total time taken to generate the page: 0.01984 seconds