Disable Component Focusable Properties

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Disable Component Focusable Properties

JeffreyLaw603
Hi there,
I'm new to apache pivot. I was quite impressed with the speed and UI of the framework
and that's the reason why I decided to migrate my POS application from Swing.
But then half way thru I realized none of the following method can be found for all the components:
setFocusable(false)
setFocusTraversalKeysEnabled(false)
setRequestFocusEnabled(false)
 
As the application required the focus always stayed in the single text field for the scanner input,
so I got to disable the focus requests for all other components.
I did tried on previewFocusedChange but still didn't managed to get it works.
Can I have some hints or example on how to create a custom focus traversal policy to the component which can allow me to disable the traversal properties also?
Does anyone can share if there's any way to do this? Thanks in advance!!
 
Reply | Threaded
Open this post in threaded view
|

Re: Disable Component Focusable Properties

Sandro Martini
Hi Jeffrey, welcome to Pivot.
First sorry for the big delay ... many time ago I wrote a simple test
class, Pivot686 (under our tests subproject) to test the related issue
(closed many time ago), and there I was forcing requestFocus on a
TextInput component, at Application startup ... maybe a trick like
this could help even in your case, when your component is losing
focus.

On the disable focus on all other components don't know it could be a
good solution (you can disable components but that would cause other
effects too). If you really need something like this we can try to
look for 2.1, but if you could post a minimal sample would be great.

Bye,
Sandro


2014-01-28 16:49 GMT+01:00 Jeffrey Law <[hidden email]>:

> Hi there,
> I'm new to apache pivot. I was quite impressed with the speed and UI of the
> framework
> and that's the reason why I decided to migrate my POS application from
> Swing.
> But then half way thru I realized none of the following method can be found
> for all the components:
> setFocusable(false)
> setFocusTraversalKeysEnabled(false)
> setRequestFocusEnabled(false)
>
> As the application required the focus always stayed in the single text field
> for the scanner input,
> so I got to disable the focus requests for all other components.
> I did tried on previewFocusedChange but still didn't managed to get it
> works.
> Can I have some hints or example on how to create a custom focus traversal
> policy to the component which can allow me to disable the traversal
> properties also?
> Does anyone can share if there's any way to do this? Thanks in advance!!
>
Reply | Threaded
Open this post in threaded view
|

RE: Disable Component Focusable Properties

JeffreyLaw603
Dear Sandro,
Thanks for your reply!
 
My issue is very simple to demo.
I actually started my project with the sample [Pivot Stock Traker].
http://pivot.apache.org/tutorials/stock-tracker.html
Exactly my issue is when you start up the demo, the focus is in the [Symbol] textbox.
But if you press [TAB] key the focus will certainly loss.
But if you can set the table's focusable property to false, the table will not receive the focus
and the focus will always stays in the [Symbol] textbox.
 
As you mentioned also I can't just disable the table component
cause I need to handle addition and deletion of the active rows as well.
Maybe I can forcing requestFocus on all other components but then I need to create also
several customized dialog in order to capture user's input selection also.
So I really hope can hear the good news on 2.1!
 
Regards,
Jeffrey

 
> Date: Wed, 12 Feb 2014 12:24:08 +0100

> Subject: Re: Disable Component Focusable Properties
> From: [hidden email]
> To: [hidden email]
>
> Hi Jeffrey, welcome to Pivot.
> First sorry for the big delay ... many time ago I wrote a simple test
> class, Pivot686 (under our tests subproject) to test the related issue
> (closed many time ago), and there I was forcing requestFocus on a
> TextInput component, at Application startup ... maybe a trick like
> this could help even in your case, when your component is losing
> focus.
>
> On the disable focus on all other components don't know it could be a
> good solution (you can disable components but that would cause other
> effects too). If you really need something like this we can try to
> look for 2.1, but if you could post a minimal sample would be great.
>
> Bye,
> Sandro
>
>
> 2014-01-28 16:49 GMT+01:00 Jeffrey Law <[hidden email]>:
> > Hi there,
> > I'm new to apache pivot. I was quite impressed with the speed and UI of the
> > framework
> > and that's the reason why I decided to migrate my POS application from
> > Swing.
> > But then half way thru I realized none of the following method can be found
> > for all the components:
> > setFocusable(false)
> > setFocusTraversalKeysEnabled(false)
> > setRequestFocusEnabled(false)
> >
> > As the application required the focus always stayed in the single text field
> > for the scanner input,
> > so I got to disable the focus requests for all other components.
> > I did tried on previewFocusedChange but still didn't managed to get it
> > works.
> > Can I have some hints or example on how to create a custom focus traversal
> > policy to the component which can allow me to disable the traversal
> > properties also?
> > Does anyone can share if there's any way to do this? Thanks in advance!!
> >
Reply | Threaded
Open this post in threaded view
|

Re: Disable Component Focusable Properties

Sandro Martini
Hi Jeffrey,
I'll try to take a look for 2.1, and post some update here ...

Thanks for now.

Bye,
Sandro


2014-02-13 15:24 GMT+01:00 Jeffrey Law <[hidden email]>:

> Dear Sandro,
> Thanks for your reply!
>
> My issue is very simple to demo.
> I actually started my project with the sample [Pivot Stock Traker].
> http://pivot.apache.org/tutorials/stock-tracker.html
> Exactly my issue is when you start up the demo, the focus is in the [Symbol]
> textbox.
> But if you press [TAB] key the focus will certainly loss.
> But if you can set the table's focusable property to false, the table will
> not receive the focus
> and the focus will always stays in the [Symbol] textbox.
>
> As you mentioned also I can't just disable the table component
> cause I need to handle addition and deletion of the active rows as well.
> Maybe I can forcing requestFocus on all other components but then I need to
> create also
> several customized dialog in order to capture user's input selection also.
> So I really hope can hear the good news on 2.1!
>
> Regards,
> Jeffrey
>
>
>> Date: Wed, 12 Feb 2014 12:24:08 +0100
>> Subject: Re: Disable Component Focusable Properties
>> From: [hidden email]
>> To: [hidden email]
>
>>
>> Hi Jeffrey, welcome to Pivot.
>> First sorry for the big delay ... many time ago I wrote a simple test
>> class, Pivot686 (under our tests subproject) to test the related issue
>> (closed many time ago), and there I was forcing requestFocus on a
>> TextInput component, at Application startup ... maybe a trick like
>> this could help even in your case, when your component is losing
>> focus.
>>
>> On the disable focus on all other components don't know it could be a
>> good solution (you can disable components but that would cause other
>> effects too). If you really need something like this we can try to
>> look for 2.1, but if you could post a minimal sample would be great.
>>
>> Bye,
>> Sandro
>>
>>
>> 2014-01-28 16:49 GMT+01:00 Jeffrey Law <[hidden email]>:
>> > Hi there,
>> > I'm new to apache pivot. I was quite impressed with the speed and UI of
>> > the
>> > framework
>> > and that's the reason why I decided to migrate my POS application from
>> > Swing.
>> > But then half way thru I realized none of the following method can be
>> > found
>> > for all the components:
>> > setFocusable(false)
>> > setFocusTraversalKeysEnabled(false)
>> > setRequestFocusEnabled(false)
>> >
>> > As the application required the focus always stayed in the single text
>> > field
>> > for the scanner input,
>> > so I got to disable the focus requests for all other components.
>> > I did tried on previewFocusedChange but still didn't managed to get it
>> > works.
>> > Can I have some hints or example on how to create a custom focus
>> > traversal
>> > policy to the component which can allow me to disable the traversal
>> > properties also?
>> > Does anyone can share if there's any way to do this? Thanks in advance!!
>> >
Reply | Threaded
Open this post in threaded view
|

Re: Disable Component Focusable Properties

Roger and Beth Whitcomb
In reply to this post by JeffreyLaw603
To disable tabbing for a particular container, in BXML you can do (for instance):
<BoxPane .... focusTraversalPolicy="$bxml:null" ... />

And of course you could call the "setFocusTraversalPolicy(null)" from Java as well (on the container).  To disable focus for a particular component only, you could wrap just that component in a BoxPane (or other container) and set the "focusTraversalPolicy" as above to null.

~Roger

On 2/13/14 6:24 AM, Jeffrey Law wrote:
Dear Sandro,
Thanks for your reply!
 
My issue is very simple to demo.
I actually started my project with the sample [Pivot Stock Traker].
http://pivot.apache.org/tutorials/stock-tracker.html
Exactly my issue is when you start up the demo, the focus is in the [Symbol] textbox.
But if you press [TAB] key the focus will certainly loss.
But if you can set the table's focusable property to false, the table will not receive the focus
and the focus will always stays in the [Symbol] textbox.
 
As you mentioned also I can't just disable the table component
cause I need to handle addition and deletion of the active rows as well.
Maybe I can forcing requestFocus on all other components but then I need to create also
several customized dialog in order to capture user's input selection also.
So I really hope can hear the good news on 2.1!
 
Regards,
Jeffrey

 
> Date: Wed, 12 Feb 2014 12:24:08 +0100
> Subject: Re: Disable Component Focusable Properties
> From: [hidden email]
> To: [hidden email]
>
> Hi Jeffrey, welcome to Pivot.
> First sorry for the big delay ... many time ago I wrote a simple test
> class, Pivot686 (under our tests subproject) to test the related issue
> (closed many time ago), and there I was forcing requestFocus on a
> TextInput component, at Application startup ... maybe a trick like
> this could help even in your case, when your component is losing
> focus.
>
> On the disable focus on all other components don't know it could be a
> good solution (you can disable components but that would cause other
> effects too). If you really need something like this we can try to
> look for 2.1, but if you could post a minimal sample would be great.
>
> Bye,
> Sandro
>
>
> 2014-01-28 16:49 GMT+01:00 Jeffrey Law [hidden email]:
> > Hi there,
> > I'm new to apache pivot. I was quite impressed with the speed and UI of the
> > framework
> > and that's the reason why I decided to migrate my POS application from
> > Swing.
> > But then half way thru I realized none of the following method can be found
> > for all the components:
> > setFocusable(false)
> > setFocusTraversalKeysEnabled(false)
> > setRequestFocusEnabled(false)
> >
> > As the application required the focus always stayed in the single text field
> > for the scanner input,
> > so I got to disable the focus requests for all other components.
> > I did tried on previewFocusedChange but still didn't managed to get it
> > works.
> > Can I have some hints or example on how to create a custom focus traversal
> > policy to the component which can allow me to disable the traversal
> > properties also?
> > Does anyone can share if there's any way to do this? Thanks in advance!!
> >

Reply | Threaded
Open this post in threaded view
|

RE: Disable Component Focusable Properties

JeffreyLaw603
That works, thanks!
But when I apply to a login dialog contains a ListButton for user Ids, TextInput for password and few PushButtons
which I extended from org.apache.pivot.wtk.Sheet and I've tried both BXML
<BoxPane .... focusTraversalPolicy="$bxml:null" ... />
or wrap that component in a container then call setFocusTraversalPolicy(null), it doesn't works.

I just want to make sure it should works for org.apache.pivot.wtk.Sheet also
so that I can continue to try on the same approach.
 
Regards,
Jeffrey


Date: Thu, 13 Feb 2014 16:22:02 -0800
From: [hidden email]
To: [hidden email]
Subject: Re: Disable Component Focusable Properties

To disable tabbing for a particular container, in BXML you can do (for instance):
<BoxPane .... focusTraversalPolicy="$bxml:null" ... />

And of course you could call the "setFocusTraversalPolicy(null)" from Java as well (on the container).  To disable focus for a particular component only, you could wrap just that component in a BoxPane (or other container) and set the "focusTraversalPolicy" as above to null.

~Roger

On 2/13/14 6:24 AM, Jeffrey Law wrote:
Dear Sandro,
Thanks for your reply!
 
My issue is very simple to demo.
I actually started my project with the sample [Pivot Stock Traker].
http://pivot.apache.org/tutorials/stock-tracker.html
Exactly my issue is when you start up the demo, the focus is in the [Symbol] textbox.
But if you press [TAB] key the focus will certainly loss.
But if you can set the table's focusable property to false, the table will not receive the focus
and the focus will always stays in the [Symbol] textbox.
 
As you mentioned also I can't just disable the table component
cause I need to handle addition and deletion of the active rows as well.
Maybe I can forcing requestFocus on all other components but then I need to create also
several customized dialog in order to capture user's input selection also.
So I really hope can hear the good news on 2.1!
 
Regards,
Jeffrey

 
> Date: Wed, 12 Feb 2014 12:24:08 +0100
> Subject: Re: Disable Component Focusable Properties
> From: [hidden email]
> To: [hidden email]
>
> Hi Jeffrey, welcome to Pivot.
> First sorry for the big delay ... many time ago I wrote a simple test
> class, Pivot686 (under our tests subproject) to test the related issue
> (closed many time ago), and there I was forcing requestFocus on a
> TextInput component, at Application startup ... maybe a trick like
> this could help even in your case, when your component is losing
> focus.
>
> On the disable focus on all other components don't know it could be a
> good solution (you can disable components but that would cause other
> effects too). If you really need something like this we can try to
> look for 2.1, but if you could post a minimal sample would be great.
>
> Bye,
> Sandro
>
>
> 2014-01-28 16:49 GMT+01:00 Jeffrey Law [hidden email]:
> > Hi there,
> > I'm new to apache pivot. I was quite impressed with the speed and UI of the
> > framework
> > and that's the reason why I decided to migrate my POS application from
> > Swing.
> > But then half way thru I realized none of the following method can be found
> > for all the components:
> > setFocusable(false)
> > setFocusTraversalKeysEnabled(false)
> > setRequestFocusEnabled(false)
> >
> > As the application required the focus always stayed in the single text field
> > for the scanner input,
> > so I got to disable the focus requests for all other components.
> > I did tried on previewFocusedChange but still didn't managed to get it
> > works.
> > Can I have some hints or example on how to create a custom focus traversal
> > policy to the component which can allow me to disable the traversal
> > properties also?
> > Does anyone can share if there's any way to do this? Thanks in advance!!
> >

Reply | Threaded
Open this post in threaded view
|

RE: Disable Component Focusable Properties

JeffreyLaw603
I've managed to get it works on org.apache.pivot.wtk.Sheet also.
But the thing is when I press the TAB key in a TextInput, I keep having the following exception
which I've no idea no to catch the exception:
 
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
 at org.apache.pivot.wtk.Container$1.check(Container.java:935)
 at org.apache.pivot.wtk.Container.assertEventDispatchThread(Container.java:958)
 at org.apache.pivot.wtk.Container.assertEventDispatchThread(Container.java:925)
 at org.apache.pivot.wtk.Container.getLength(Container.java:260)
 at org.apache.pivot.wtk.skin.ContainerSkin$IndexFocusTraversalPolicy.getNextComponent(ContainerSkin.java:68)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:543)
 at org.apache.pivot.wtk.Component.transferFocus(Component.java:2435)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:540)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:551)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:551)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:551)
 at org.apache.pivot.wtk.Component.transferFocus(Component.java:2435)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:560) ....

 
Reply | Threaded
Open this post in threaded view
|

Re: Disable Component Focusable Properties

Roger and Beth Whitcomb
Hi Jeffrey,
    That looks like an infinite recursion problem.  What did you do to make the tabbing work within a Sheet?  My guess would be that whatever you did is causing this.  But, in case it is a Pivot bug, could you provide a small test case to reproduce it so we can take a look?

Thanks,
~Roger

On 2/16/14 11:58 PM, Jeffrey Law wrote:
I've managed to get it works on org.apache.pivot.wtk.Sheet also.
But the thing is when I press the TAB key in a TextInput, I keep having the following exception
which I've no idea no to catch the exception:
 
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
 at org.apache.pivot.wtk.Container$1.check(Container.java:935)
 at org.apache.pivot.wtk.Container.assertEventDispatchThread(Container.java:958)
 at org.apache.pivot.wtk.Container.assertEventDispatchThread(Container.java:925)
 at org.apache.pivot.wtk.Container.getLength(Container.java:260)
 at org.apache.pivot.wtk.skin.ContainerSkin$IndexFocusTraversalPolicy.getNextComponent(ContainerSkin.java:68)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:543)
 at org.apache.pivot.wtk.Component.transferFocus(Component.java:2435)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:540)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:551)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:551)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:551)
 at org.apache.pivot.wtk.Component.transferFocus(Component.java:2435)
 at org.apache.pivot.wtk.Container.transferFocus(Container.java:560) ....

 

Reply | Threaded
Open this post in threaded view
|

RE: Disable Component Focusable Properties

JeffreyLaw603
 
Hi Roger,
I think I found the roof of the problem.
As per what you suggested, in the sample stock_tracker_window.bxml
I tried to assign an bxml:id to each container so that I call the setFocusTraversalPolicy(null)
to prevent the focus goes to the other components in this case the TableView.
 
<TablePane bxml:id="pane1" styles="{padding:8, horizontalSpacing:6, verticalSpacing:6}">
 :
 <SplitPane bxml:id="pane2" splitRatio="0.4">
  :
  <ScrollPane bxml:id="pane3" horizontalScrollBarPolicy="fill_to_capacity" verticalScrollBarPolicy="fill_to_capacity">
   :
   <StackPane bxml:id="pane4">
                  <TableView bxml:id="stocksTableView" selectMode="multi" styles="{showHorizontalGridLines:false}">
 
I found that only when I call pane1.setFocusTraversalPolicy(null) which is TablePane and the rest are all fine.
But the strange things is I have no where to catch this exception, anyway there's a way solved the issue.
Thanks,
Jeffrey

Reply | Threaded
Open this post in threaded view
|

Maximize TablePane in the TabPane

JeffreyLaw603
In reply to this post by JeffreyLaw603
Hi Pivot,
I've tried to extend the sample stock tracker application
and would like to create a TabPane with few tabs and add the whole page of the stock tracker window into
the <TabPane.tabData>.
<stocktracker:StockTrackerWindow title="%stockTracker" maximized="true"
    xmlns:bxml="http://pivot.apache.org/bxml"
    xmlns:content="org.apache.pivot.wtk.content"
    xmlns:stocktracker="org.apache.pivot.tutorials.stocktracker"
    xmlns="org.apache.pivot.wtk">
    <TabPane xmlns:bxml="http://pivot.apache.org/bxml"
     xmlns:content="org.apache.pivot.wtk.content"
     xmlns="org.apache.pivot.wtk">
 <BoxPane styles="{horizontalAlignment:'center', verticalAlignment:'center'}">
        <TabPane.tabData>
            <content:ButtonData text="Bell"/>
        </TabPane.tabData>
        <BoxPane styles="{backgroundColor:'#0096D5', horizontalAlignment:'right'}">
 <TablePane>
 :
 :
 </TablePane>
</stocktracker:StockTrackerWindow>
 
The problem is how can I make the stock tracker window (TablePane) maximized in this <TabPane.tabData>?
The tutorial mentioned creating a label and specify the preferred dimension:
<Label text="240x180" preferredWidth="240" preferredHeight="180"/>
But the application will be run in several different platform and screen size and I need to ensure
the tab container is maximized without keeps change the dimension and compiling the program.
 
Any helps and advices would be appreciated!
Jeffrey

Reply | Threaded
Open this post in threaded view
|

RE: Maximize TablePane in the TabPane

JeffreyLaw603
I got it myself, just simply just replace the BoxPane with FillPane will do!

           
Reply | Threaded
Open this post in threaded view
|

Re: Maximize TablePane in the TabPane

Roger and Beth Whitcomb
That's exactly what FillPane is good for.  Great!

~Roger

On 2/19/14 8:27 PM, Jeffrey Law wrote:
I got it myself, just simply just replace the BoxPane with FillPane will do!

           

Reply | Threaded
Open this post in threaded view
|

RE: Disable Component Focusable Properties

Ripgiblet
In reply to this post by JeffreyLaw603

Hi All,

 

I have a similar problem to this, I don’t want buttons on a touch screen grabbing focus away from where the text is supposed to be written…

 

There is an onFocusChanged in the ComponentStateListener, but since this is for abstract keyboards with lots of buttons that I currently use by the action and TextKey Value…

I would prefer a different way to do this…

So basically I want to prevent a large number of buttons from ever grabing the focus?

I have tried focusTraversalPolicy="$bxml:null" but does not seem to work…

 

Anybody got any ideas on how to prevent buttons from changing the focus when clicked? Some sort of NotFocusable flag?

 

Regards,

Mark.

 

From: Jeffrey Law [mailto:[hidden email]]
Sent: Tuesday, 18 February 2014 10:20 PM
To: [hidden email]
Subject: RE: Disable Component Focusable Properties

 

 
Hi Roger,
I think I found the roof of the problem.
As per what you suggested, in the sample stock_tracker_window.bxml
I tried to assign an bxml:id to each container so that I call the setFocusTraversalPolicy(null)
to prevent the focus goes to the other components in this case the TableView.
 
<TablePane bxml:id="pane1" styles="{padding:8, horizontalSpacing:6, verticalSpacing:6}">
 :
 <SplitPane bxml:id="pane2" splitRatio="0.4">
  :
  <ScrollPane bxml:id="pane3" horizontalScrollBarPolicy="fill_to_capacity" verticalScrollBarPolicy="fill_to_capacity">
   :
   <StackPane bxml:id="pane4">
                  <TableView bxml:id="stocksTableView" selectMode="multi" styles="{showHorizontalGridLines:false}">
 
I found that only when I call pane1.setFocusTraversalPolicy(null) which is TablePane and the rest are all fine.
But the strange things is I have no where to catch this exception, anyway there's a way solved the issue.
Thanks,
Jeffrey

Reply | Threaded
Open this post in threaded view
|

RE: Disable Component Focusable Properties

JeffreyLaw603
Hi Mark,
Previously I tried focusTraversalPolicy="$bxml:null" also didn't managed to get it work.
I got it work with the setFocusTraversalPolicy(null).
Just as per what Roger mentioned previously, you must wrap those buttons in a container and call the function.
For example:
@BXML
private Button addSymbolButton = null;
@BXML
private BoxPane mainPane = null;
mainPane.add(addSymbolButton);
mainPane.setFocusTraversalPolicy(null);

Hope this help.
Jeffrey
 
 


 
Reply | Threaded
Open this post in threaded view
|

RE: Disable Component Focusable Properties

Ripgiblet

Hi Jeffrey,

 

Thanks for your help I will try, currently battling with https://github.com/influence160/fazet-pivot/blob/master/README.md

To try and get cell selection tableview sorted, that way when I select a cell I can at least record which cell was clicked and then edit it (also maybe return focus) when another button is clicked:/

 

Regards,

Mark.

 

From: Jeffrey Law [mailto:[hidden email]]
Sent: Tuesday, 25 February 2014 10:47 AM
To: [hidden email]
Subject: RE: Disable Component Focusable Properties

 

Hi Mark,
Previously I tried focusTraversalPolicy="$bxml:null" also didn't managed to get it work.
I got it work with the setFocusTraversalPolicy(null).
Just as per what Roger mentioned previously, you must wrap those buttons in a container and call the function.
For example:
@BXML
private Button addSymbolButton = null;
@BXML
private BoxPane mainPane = null;
mainPane.add(addSymbolButton);
mainPane.setFocusTraversalPolicy(null);

Hope this help.
Jeffrey