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 » Community » Newbie corner » Help needed with OptionTree
Help needed with OptionTree [message #60285] Fri, 10 November 2023 22:33 Go to previous message
Tom1
Messages: 1301
Registered: March 2007
Ultimate Contributor
Hi,

I just cannot figure out how to do these in OptionTree:

- Have Option operating only from the checkbox, not the text label
- Select items and show the selection (at least one at a time) from the text label
- Support WhenLeftDouble from the text label
- Support WhenBar from the text label
- Support Internal DnD from the text label (to change ordering of items)

This is what I tried, but the checkbox seems to own the text label and all events get stuck there:

#include "CtrlLib/CtrlLib.h"

using namespace Upp;

struct App : TopWindow {
	OptionTree   otree;

	typedef App CLASSNAME;

	void DropInsert(int parent, int ii, PasteClip& d){
		otree.AdjustAction(parent, d);
		if(AcceptInternal<OptionTree>(d, "mytreedrag")) otree.InsertDrop(parent, ii, d);
	}

	void Drag(){
		otree.DoDragAndDrop(InternalClip(otree, "mytreedrag"), otree.GetDragSample());
	}
	
	Array<Option> opts;

	App() {
		Add(otree.SizePos());
		
		otree.NoRoot();
		otree.ManualMode();
		
		for(int i=0;i<5;i++){
			otree.Add(0, Image(), opts.Add(), Format("Item %d",i+1));
			if(i==0){
				otree.Add(1, Image(), opts.Add(), String("SubItem 1"));
				otree.Add(1, Image(), opts.Add(), String("SubItem 2"));
			}
		}

		otree.WhenBar = [&](Bar &bar){ bar.Add(Format("Menu for item %d", otree.GetCursor()), [&](){ PromptOK("Menu item selected"); }); };
		otree.WhenLeftDouble = [&](){ PromptOK("Left double-click"); };
		otree.WhenDropInsert = THISBACK(DropInsert);
		otree.WhenDrag = THISBACK(Drag);
		otree.NoCursor(false);
		Sizeable();
	}
};

GUI_APP_MAIN
{
	App().Run();
}


Any ideas how to go around this issue?

Thanks and best regards,

Tom
 
Read Message
Read Message
Read Message
Previous Topic: How do I write string_view to Cout() without copying to a String?
Next Topic: Tutorial update(s)
Goto Forum:
  


Current Time: Tue Apr 29 00:21:29 CEST 2025

Total time taken to generate the page: 0.00697 seconds