Home » Community » Newbie corner » Help needed with OptionTree
Help needed with OptionTree [message #60285] |
Fri, 10 November 2023 22:33  |
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
|
|
|
Goto Forum:
Current Time: Tue Apr 29 00:21:29 CEST 2025
Total time taken to generate the page: 0.00697 seconds
|