Defining buddies for labels

1 view
Skip to first unread message

Oliver Friedrich

unread,
Apr 28, 2010, 3:30:47 AM4/28/10
to QxTransformer Mailing List
Hi Serge,

is there a way that a widget becomes the buddy of a label?
So the widget would get the focus if the label gets clicked.

Perhaps it could be definied like the following example if there exists
nothing for it in Qxt:

> <qx:label content="{js}this.tr('Title')" qxt:row="0" qxt:column="1">
> <qx:textField value="TestTitle" qxt:row="1" qxt:column="1"/>
> </qx:label>


Expected result would be like something like this:
> var qxLabel2 = new qx.ui.basic.Label(this.tr('Title'));
> qxLabel2.setContent(this.tr('Title'));
> qxGroupBox1.add(qxLabel2, {
> row: 0,
> column: 1
> });
> var qxTextField2 = new qx.ui.form.TextField("TestTitle");
> qxTextField2.setValue("TestTitle");
> qxGroupBox1.add(qxTextField2, {
> row: 1,
> column: 1
> });
> qxLabel2.setBuddy(qxTextField2);



Cheers,
Oliver

--
You received this message because you are subscribed to the Google Groups "QxTransformer" group.
To post to this group, send email to qxtran...@googlegroups.com.
To unsubscribe from this group, send email to qxtransforme...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/qxtransformer?hl=en.

Siarhei Barysiuk

unread,
Apr 28, 2010, 4:08:40 AM4/28/10
to qxtran...@googlegroups.com
Hi,

This should work this way:

<qx:textField id="myTextField" value="TestTitle" qxt:row="1"
qxt:column="1"/>
<qx:label content="{js}this.tr('Title')" qxt:row="0" qxt:column="1"
buddy="{js}myTextField"/>

Let me know if you have problems with this snippet.

Thanks,
Serge

Oliver Friedrich

unread,
Apr 28, 2010, 4:22:40 AM4/28/10
to qxtran...@googlegroups.com
Hi Serge,

this does the trick. But it looks a little bit unnatural to define first
a textfield and than the associated label.

Would it be a big task to define a nested structure like in my example?
Or would this conflict with something else?

Cheers,
Oliver

Christian Boulanger

unread,
Apr 28, 2010, 4:28:47 AM4/28/10
to qxtran...@googlegroups.com
True, there is a a problem with the order of variable definition here. Even qxt:scope="this" doesn't help because the buddy property needs a initialized object ... One can go with 

<qx:label id="myLabel" content="{js}this.tr('Title')" qxt:row="0" qxt:column="1" />
<qx:textField id="myTextField" value="TestTitle" qxt:row="1" qxt:column="1"/>
<qxt:script> myLabel.setBuddy(myTextField)</qxt:script>

But of course this is not very pretty. We would need to write a separate template for that.. Can you live with this workaround for the moment, though`?

C. 

2010/4/28 Oliver Friedrich <oli...@familie-friedrich.de>

Siarhei Barysiuk

unread,
Apr 28, 2010, 4:45:50 AM4/28/10
to qxtran...@googlegroups.com
There is a conceptual issue I think... Defining text field in label
looks odd to me since in almost all cases parent is a container and
child is a element which is added to container. So, if translate your
example keeping in mind my logic, it will look like you're trying to
add text field to label which is obviously incorrect.

What do you think? Christian?

Serge

Christian Boulanger

unread,
Apr 28, 2010, 4:50:34 AM4/28/10
to qxtran...@googlegroups.com
Yes, I also think this should be solved differently. maybe an attribute in the tag that is defined later -  usually the input widget - so something like <qx:textField isBuddyFor="myLabel" ...> which would simply generate myLabel.setBuddy(myTextfield)..

C. 

2010/4/28 Siarhei Barysiuk <s.bar...@gmail.com>
To unsubscribe from this group, send email to qxtransforme...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/qxtransformer?hl=en.


--
You received this message because you are subscribed to the Google Groups "QxTransformer" group.
To post to this group, send email to qxtran...@googlegroups.com.
To unsubscribe from this group, send email to qxtransforme...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/qxtransformer?hl=en.

Oliver Friedrich

unread,
Apr 28, 2010, 5:13:13 AM4/28/10
to qxtran...@googlegroups.com
Hi Christian,
at the moment i can live with the workaround provided by Serge.

Your sinplet has the right order of elements but as you have mentioned,
it's not very pretty. "buddy" is a property of label and should be
handled directly by the label tag.

Cheers,
Oliver



Am 28.04.2010 10:28, schrieb Christian Boulanger:
> True, there is a a problem with the order of variable definition here.
> Even qxt:scope="this" doesn't help because the buddy property needs a
> initialized object ... One can go with
>
> <qx:label id="myLabel" content="{js}this.tr <http://this.tr>('Title')"
> qxt:row="0" qxt:column="1" />
> <qx:textField id="myTextField" value="TestTitle" qxt:row="1"
> qxt:column="1"/>
> <qxt:script> myLabel.setBuddy(myTextField)</qxt:script>
>
> But of course this is not very pretty. We would need to write a separate
> template for that.. Can you live with this workaround for the moment,
> though`?
>
> C.
>
> 2010/4/28 Oliver Friedrich <oli...@familie-friedrich.de
> <mailto:oli...@familie-friedrich.de>>
>
> Hi Serge,
>
> this does the trick. But it looks a little bit unnatural to define first
> a textfield and than the associated label.
>
> Would it be a big task to define a nested structure like in my example?
> Or would this conflict with something else?
>
> Cheers,
> Oliver
>
>
>
> Am 28.04.2010 10:08, schrieb Siarhei Barysiuk:
> > Hi,
> >
> > This should work this way:
> >
> > <qx:textField id="myTextField" value="TestTitle" qxt:row="1"
> > qxt:column="1"/>
> > <qx:label content="{js}this.tr <http://this.tr>('Title')"
> qxt:row="0" qxt:column="1"
> > buddy="{js}myTextField"/>
> >
> > Let me know if you have problems with this snippet.
> >
> > Thanks,
> > Serge
> >
> >
> > On Apr 28, 2010, at 10:30 AM, Oliver Friedrich wrote:
> >
> >> Hi Serge,
> >>
> >> is there a way that a widget becomes the buddy of a label?
> >> So the widget would get the focus if the label gets clicked.
> >>
> >> Perhaps it could be definied like the following example if there
> exists
> >> nothing for it in Qxt:
> >>
> >>> <qx:label content="{js}this.tr <http://this.tr>('Title')"
> qxt:row="0" qxt:column="1">
> >>> <qx:textField value="TestTitle" qxt:row="1" qxt:column="1"/>
> >>> </qx:label>
> >>
> >>
> >> Expected result would be like something like this:
> >>> var qxLabel2 = new qx.ui.basic.Label(this.tr
> <http://this.tr>('Title'));
> >>> qxLabel2.setContent(this.tr <http://this.tr>('Title'));
Reply all
Reply to author
Forward
0 new messages