cancel
Showing results for 
Search instead for 
Did you mean: 

how to remove the focus from a tree?

Former Member
0 Kudos

Hello,

how can I remove the focus from a tree, so that

none of the elements in the tree is selected?

I have tried using the following methods:

setTreeSelection(null);

setLeadSelection(IWDNode.NO_SELECTION);

None of them worked.

Any help highly appreciated.

Greetings,

Tomek.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Tomasz,

Try the following code.

IPrivateLeftView.IRootNodeElement se = wdContext.nodeRootNode().getRootNodeElementAt(0);

wdContext.nodeRootNode().setTreeSelection(se);

Here RootNode is the main root node in my context.

It will focus on the top node and so initially you can get tree in closed state.

Let me know the status.

Regards,

Bhavik

Former Member
0 Kudos

Hi Bhavik,

thanks for your piece of advice, but what I want

to achieve is to remove the focus from the entire

tree (rather than move it to the root node).

I wan the tree to remain expanded, but without

any node selected. I have managed to achieve it

when the page is opened initially. However when

the user selects any node in the tree, and than

leaves the tree by selecting any other UI element,

the tree node still remains selected (i.e.

hihglighted).

Greetings,

Tomek.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

May be you can use .requestfocus() in the runtime to change the focus to some other control.

Regards, anilkumar

Former Member
0 Kudos

Hi Anilkumar,

for which class/object is this (requestfocus()) method

available? It doesn't seem to be available for the context

nodes/elements.

Greetings,

Tomek.

Former Member
0 Kudos

Hi,

It is available only for UI element objects..

Former Member
0 Kudos

Hi,

sorry for asking (possibly) very basic questions,

but could you please show me the pattern I can use

to get access to a user interface object (e.g. a

tree)?

It seems I should get IWDUIElement, but how?

Many thanks,

Tomek.

Former Member
0 Kudos

Hi Tomek / Bharathwaj,

Did u check with this method

wdThis.wdGetAPI().requestFocus(IWDNodeElement nodeElement, IWDAttributeInfo attribute)

IWDAttributeInfo attribute

= wdContext.nodeXYZ().getNodeInfo().getAttribute(

IPrivateMyView.IXYZElement.ABC);

wdThis.wdGetAPI().requestFocus(wdContext.currentXYZElement(), attribute);

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Tomek,

Chk the following code

IWDTree tree = (IWDTree)view.getElement(<<name of the Tree UI element>>);

tree.requestFocus();

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Santhosh,

sorry, but I do not understand what does the "view"

stand for in your code sample?

IWDTree tree = (IWDTree)view.getElement...

Greetings,

Tomek.

Former Member
0 Kudos

Hi Tomek,

For getting any of the UI components you need to have the "view" object reference. This will be available in the "wdDoModifyView()".

But setting the focus using the UI element is not advisible.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Santhosh,

thanks for your kind help, but unfortunately it didn't

work in my case. It seems to me the problem is not that

the focus is not transferred from one UI element to

the other. Rather than that the problem is that

it does not leave the "old" element.

I will describe it with my example: I have 2 trees

displayed on one page: A & B. Initially only one

node of the A tree is selected (has focus). So far,

so good. But when the user clicks on a node of

the B tree, the node previously selected in the

A tree is still highlighted. So the user sees both

nodes (one in tree A, and another one in tree B)

highlighted (selected).

Greetings,

Tomek.

Former Member
0 Kudos

Hi Tomek,

The one what you are talking is selected tree node, for this we can not use the "requestFocus()", by saying "requestFocus()" to another UI element, will not remove the tree selection.

This behaves similar to Table UI element, if one row is selected in a table and the focus is moved to another UI element also, the selected row will not be deselected.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi,

I think this might work.. You must have binded the tree with a node..

use wdContext.node<name>().clearSelection()

Regards

Bharathwaj

Former Member
0 Kudos

Hi Bharathwaj,

unfortunately it doesn't work in my case.

But there is one more very interesting observation...

Now I have managed to remove the focus from B tree

when the user clicks on a node of A tree. I did it

with the following code:

IWDTree foldersTree =

(IWDTree)thisView.getElement("TreeFolders");

foldersTree.requestFocus();

But this very same technique does not work when

applied to the tree A (i.e. when the user clicks

on a node of the B tree). Will investigate it

further...

Greetings,

Tomek.

Former Member
0 Kudos

Hello,

it seems I have found a (dirty) workaround to this

problem. If anyone is interested, details below:

When the user clicks on a tree node (say A tree),

I do the following:

1. request focus on the tree selected by the user

(say B tree):

IWDTree foldersTree =

(IWDTree)thisView.getElement("TreeFolders");

foldersTree.requestFocus();

2. invalidate the A tree (which causes the tree

to disappear)

wdThis.wdGetContext().nodeInbox().invalidate();

3. recreate the A tree (filling the context nodes)

4. unselect the A tree:

wdContext.nodeInbox().setLeadSelection(IWDNode.NO_SELECTION);

Thanks a lot to all of you who have responded.

Greetings,

Tomek.

Former Member
0 Kudos

Check your context nodes -- it seems that they have either selection cardinality 1..1 (i.e. mandatory selection) or has initializeLeadSelection proprty set to true (default, you need false).

VS

Former Member
0 Kudos

> Check your context nodes -- it seems that they have

> either selection cardinality 1..1 (i.e. mandatory

> selection) or has initializeLeadSelection proprty

> set to true (default, you need false).

The cardinality is OK (0..1). The initializeLeadSelection

property was set to true, but changing it to false didn't

help. Initially (just after the page is displayed)

everything looks fine (the tree is not selected), but

after the user clicks on any node, and then tries to

move the focus to some other UI element, the tree

node remains highlighted.

I have managed to move the tree focus to the root

node, but what I want to achieve is to remove the

focus (highlighting) from the tree at all.

Greetings,

Tomek.

Former Member
0 Kudos

Try keeping the focus on someother UI element.