[Gambas-user] Clicking a TreeView item by program

Rolf-Werner Eilert eilert-sprachen at ...221...
Mon Nov 30 10:06:04 CET 2015


Am 27.11.2015 12:49, schrieb Rolf-Werner Eilert:
> Am 25.11.2015 18:07, schrieb Benoît Minisini:
>> 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,
>>
> And here we go again: There's another place with a Null Object error.
> This time, there is a dialog which is called when a certain is clicked
> in the TreeView. The dialog asks for a new entry for the TreeView. To
> make things short, this is what happens:
>
>     dlgNeuerName.ShowDialog
>
>     baum.MoveCurrent
>     baum.Current.Expanded = True
> 'no problem up to here
> 'now read all data of the children into a list "ls"
>     Do
>       If baum.MoveBelow() Then Break
>       If Left$(baum.Item.Key, 1) <> "#" Then Break
>       ls.Add(baum.Item.Text & Chr$(6) & baum.Item.Key)
>     Loop
> 'no problem
>     baum.MoveCurrent    'print baum.Current.Key shows: everything ok up
> to here, but:
>     baum.Item.Clear
>
> Here is the Null Object error again. I tried:
>
> baum.Current.Clear (instead of Item)
>
> as well as
>
> baum.MoveCurrent
> baum.MoveParent
> baum.Item.Clear
>
> No chance.
>
> Any idea? Thank you! And if you are not there right now - have a nice
> weekend!
>
> Rolf
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
You haven't had an idea about this, have you?

Regards
Rolf





More information about the User mailing list