Page 1 of 1

Listview.GetSelection strangeness

Posted: Wed May 27, 2026 7:41 pm
by bitRocky
I have a multiselect listview and encounter some strangeness.
If I click on an entry for the first time, I get the correct entry from Listview.GetSelection, but if I then click another entry, GetSelection returns the previously clicked entry and not the entry I currently clicked on!?

If I start to select multiple entries, GetSelection returns the correct entries.
But if I then click on another entry (so all selected entries will be deselected), GetSelection returns the previously selected entries.

I know that GetSelection doesn't return the active entry if multiple entries are selected.

If I browse through the listiview by cursor keys and select/deselect some entries everything is returned correct.

Here is short example:

Code: Select all

@REQUIRE "RapaGUI"
; just some aliases
set = moai.set
get = moai.get
dom = moai.DoMethod

Function p_Active()
	t = moai.DoMethod("lv", "GetSelection")
	f$ = ""
	DebugPrint("ListItems(t) = "..ListItems(t))
	DebugPrint("t[0]     = "..IIf(ListItems(t) > 0, t[0], -1)..", isSel = "..dom("lv", "Select", t[0], "Ask"))
	DebugPrint("active   = "..get("lv", "active"))
	For Local i=0 To ListItems(t)-1
		DebugPrint("t["..i.."] = "..t[i])
		f$ = f$..dom("lv", "GetEntry", t[i])
	Next
	;Textentry
	set("strTest", "text", f$)
EndFunction

moai.CreateApp([[
<?xml version="1.0" encoding="iso-8859-1"?>
<application>
	<window title="Test program" width="300">
		<vgroup>
			<listview id="lv" notify="active" multiselect="true" >
				<column>
					<item>0</item>
					<item>1</item>
					<item>2</item>
					<item>3</item>
					<item>4</item>
					<item>5</item>
					<item>6</item>
					<item>7</item>
					<item>8</item>
					<item>9</item>
				</column>
			</listview>
			<TextEntry id="strTest" />
		</vgroup>
	</window>
</application>
]])

InstallEventHandler({
	RapaGUI = Function(msg) If msg.id = "lv" Then Return(p_Active()) EndFunction
})

Repeat
WaitEvent
Forever

Re: Listview.GetSelection strangeness

Posted: Thu May 28, 2026 7:21 am
by plouf
if i understand look ok to me check video ->https://limewire.com/d/DFb7n#AdgL7qVd19

p.s what os ?

Re: Listview.GetSelection strangeness

Posted: Thu May 28, 2026 10:33 am
by bitRocky
Yeah, yours look correct.
I'm using MorphOS, seems to be only there