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 » TabCtrl » Why does this code hang?
Why does this code hang? [message #45260] Sun, 25 October 2015 12:59 Go to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
(debian 64-bit)

Based on reply by unodgs: http:// www.ultimatepp.org/forums/index.php?t=msg&th=6809&go to=36746&#msg_36746
The following code hangs when a tab is clicked:

#include <CtrlLib/CtrlLib.h>
#include <TabBar/TabBar.h> //must add package TabBar

using namespace Upp;

struct test_tabbar : public TopWindow 
{
	typedef test_tabbar CLASSNAME;
	TabBar TB;
	test_tabbar();
	void ontab();
	
};

test_tabbar::test_tabbar()
{
	Title("test_tabbar");
	Add(TB);
	TB.HSizePosZ(0, 0).VSizePosZ(0, 0);
	TB.AddKey("one", "tab one");
	TB.AddKey("two", "tab two");
	TB.AddKey("three", "tab three");
	TB.WhenAction = THISBACK(ontab);
}

void test_tabbar::ontab()
{
	PromptOK(TB.Get(TB.GetKey(TB.GetHighlight())).ToString());
}

GUI_APP_MAIN
{
	test_tabbar().Run();
}

[Updated on: Sun, 25 October 2015 13:00]

Report message to a moderator

Re: Why does this code hang? [message #45262 is a reply to message #45260] Mon, 26 October 2015 06:28 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi Slashupp,

TB.GetHighlight() will return int.

TB.GetKey() will fail to return any value because it will expect one of the Keys you have added as input argument.

TB.GetKey(TB.GetHighlight()) -- This is giving you error.

All the keys added are Strings.


Warm Regards

Deepak
Re: Why does this code hang? [message #45263 is a reply to message #45262] Mon, 26 October 2015 08:23 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
No, that code is correct - it works as expected, after/when the prompt is shown, the app hangs
Re: Why does this code hang? [message #45274 is a reply to message #45263] Mon, 26 October 2015 18:58 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
try this:

void test_tabbar::ontab()
{
	if(TB.FindKey(TB.GetHighlight()) >= 0)
	{
		PromptOK(TB.Get(TB.GetKey(TB.GetHighlight())).ToString());
	}
	else
	{
		PromptOK("key Not found");
	}
	
	PromptOK(TB.Get(TB.GetKey(TB.GetCursor())).ToString());
}



regards
omari.
Re: Why does this code hang? [message #45276 is a reply to message #45274] Tue, 27 October 2015 07:21 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
GetHighlight() returns index into tabs stack and will not work in this case (with FindKey())

the keys i use are strings
i know they are valid when any tab is selected
the code i wrote works until the prompt is displayed and then it hangs the tty and i have to use another tty to kill the app

Re: Why does this code hang? [message #45293 is a reply to message #45276] Wed, 28 October 2015 11:29 Go to previous message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
Embarassed
your code works as expected on Win 7, without hangs.

i will test with debian at home.



regards
omari.
Previous Topic: Tabs at bottom of TabCtrl
Next Topic: How can I change the TabCtrl font size and weight?
Goto Forum:
  


Current Time: Thu Mar 28 23:37:11 CET 2024

Total time taken to generate the page: 0.00993 seconds