U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » ArrayCtrl in Multiselect mode
ArrayCtrl in Multiselect mode [message #59258] Wed, 07 December 2022 05:55
pvictor is currently offline  pvictor
Messages: 75
Registered: December 2015
Member
Hi!

ArrayCtrl in Multiselect mode generates 2 events WhenSel on each mouse click. This may cause problems in some cases.
Code:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct Test : TopWindow {
	ArrayCtrl ar;
	Test() {
		SetRect(0, 0, 640, 480);
		Add(ar.SizePos());
		ar.MultiSelect();
		ar.AddColumn("Col 1", 1);
		for (int i=0; i<20; ++i) ar.Add(i);
		ar.WhenSel = [this] {
			RDUMP(ar.GetCursor());
		};
	}
};

GUI_APP_MAIN {
	Test().Run();
}

Log:
ar.GetCursor() = 2
ar.GetCursor() = 2
ar.GetCursor() = 4
ar.GetCursor() = 4
ar.GetCursor() = 8
ar.GetCursor() = 8

Currently, I have to add this code to the event handler:
	static int i0=-1;
	int i=ar.GetCursor();
	if (i==i0 || (i0=i)<0) return;


Best regards,
Victor
Previous Topic: GridCtrl enhancement proposition
Next Topic: multi column droplist?
Goto Forum:
  


Current Time: Tue May 05 19:49:49 GMT+2 2026

Total time taken to generate the page: 0.00417 seconds