[Gambas-user] Clicking a TreeView item by program
Benoît Minisini
gambas at ...1...
Wed Nov 25 18:07:25 CET 2015
Le 25/11/2015 17:58, Rolf-Werner Eilert a écrit :
>
> Am 25.11.2015 13:59, schrieb Benoît Minisini:
>> Le 25/11/2015 09:07, Rolf-Werner Eilert a écrit :
>>> In one of my older projects, there was kinda timeout after 2 minutes of
>>> inactivity. In the TreeView the next parent was jumped at and "clicked"
>>> to let the data of the child disappear from screen. This is the code,
>>> "baum" is the TreeView:
>>>
>>> baum.MoveParent
>>> baum.Item.Selected = True
>>> baum_Click
>>>
>>> Now in Gambas3, when the program doesn't have the focus anymore, I get a
>>> "Null object" error at the baum.Item.Selected line.
>>>
>>> I know, Item is for the internal cursor. And I want the real cursor. But
>>> Current is readonly, right? So how can I set the visible cursor? Or does
>>> the error come from something quite different?
>>>
>>> Regards
>>> Rolf
>>>
>> Provide more code. If baum.Item returns NULL, that should mean that
>> MoveParent() failed.
>>
>
> Ok, that gives me an idea where to look.
>
> There is not much more code:
>
> Public Sub Timer2_Timer()
>
> If PrivacyPause Then
> Timer2EventZlr = 1
> Return
> End If
>
> If Timer2EventZlr > 0 Then
> Timer2EventZlr = 0
>
> Else
> If tab.Index = 0 Then
> If Left$(baum.Current.Key, 1) = "#" Then
> baum.MoveParent
> baum.Item.Selected = True
> baum_Click
> End If
> Else
> tab.Index = 0
> End If
>
> End If
>
> End
>
> Every 60 seconds the Timer looks if there is another Tab than 0 open. If
> yes, the first action is to set it back to the first Tab. The next time,
> it should set the cursor from the personal entry (child) back to its
> parent, so the personal data aren't shown anymore and you cannot see who
> was clicked.
>
> Of course, there is a check for activity at some places in the program,
> but this still seems to run as expected. The problem appears only when
> the program window is hidden and has no focus or when it's on another
> screen. Maybe the TreeView "forgets" about its position then?
>
> Regards
> Rolf
>
No. I guess that accessing baum.Current does not move the Item cursor
anymore. Just try to add baum.MoveCurrent before baum.MoveParent, it
should fix your problem.
Regards,
--
Benoît Minisini
More information about the User
mailing list