Page 1 of 1

Tree View Issue

Posted: Fri Mar 09, 2018 3:49 pm
by soa
I have a tree view to which I'm adding various RPs. I'm catching the #treeItems.ItemGotFocus event to determine which is the active item.

One of my RPs has a text box element and when I click into the textbox the above event fires.

But another contains a DateTime Picker and if I click on the white area of the date box or I use the event fires but if instead I click on the first part of the date (as in 22 in 22/12/2017) then the itemGotFocus does not fire. If I click on the down arrow to the month view the itemGotFocus again does not fire.

Since anyone change. How can I capture these events in the RP and propagate them back to the tree as itemGotFocus events.

Cheers

Re: Tree View Issue

Posted: Mon Mar 12, 2018 12:08 pm
by GregSippel
Soa,

The answer is very close to a question asked by jyoung, see here viewtopic.php?f=3&t=1695&sid=3402ea900c ... 9284dc0f17

In your Tree Item Design, signal an event when the DateTime Picker get focus like this

Code: Select all

Define_Evt Name(DateTimeGotFocus)


Evtroutine Handling(#DateTime1.GotFocus)

#SYS_WEB.Console.Log( ('Item Design Evtroutine Handling(#DateTime1.GotFocus)') )
Signal Event(DateTimeGotFocus)

Endroutine

Then in the component that uses the tree view, you need the capture the event. To do this first we need a global variable to hold the reference item we wish to here events from

Code: Select all

Define_Com Class(#gbsTestTreeEventsDesign) Name(#CurrentDesign) Reference(*DYNAMIC)
Now we have this, we can capture the reference item like this

Code: Select all

Evtroutine Handling(#Tree1.ItemMouseHover) Item(#Item)

#CurrentDesign <= (#Item.Design *As #gbsTestTreeEventsDesign)

Endroutine
and finally, we can hear the events via this

Code: Select all

Evtroutine Handling(#CurrentDesign.DateTimeGotFocus) Com_Sender(#Sender)

#SYS_WEB.console.log( ('#Tree1.ItemGotFocus by sender ' + #Sender.name + ' and Item ' + #Tree1.CurrentItem.Entry.AsString) )

Endroutine
Hope this helps.

Cheers
Greg