Closed darrenloasby closed 12 years ago
Hello!
I believe your problem arises due to lousy documentation. If you set a function to the click
property of an element, it will be automatically bound. However this behaviour only applies to the click
property - all other events have to be set in an object on the events
property to be automatically bound.
Also, in this events
object, you can specify another object on the app
property. All functions found here will be bound to the global app events, but called upon the element. Example time!
K({
type: 'window',
children: [{
type: 'label',
top: 10,
width: 200,
height: 20,
text: 'Click me!',
click: K.log
},{
type: 'textfield',
top: 40,
width: 200,
height: 40,
click: K.log,
hintText: 'enter text please',
borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
events: {
change: K.log,
'return': K.log,
app: {
customglobalevent: K.log
}
}
}]
}).open();
Hope this helps, and big thanks for the heads up and flattery! /J
Amazing. Thank you so much for your work, and rapid and concise assistance!
You're most welcome!
Sorry about the somewhat lousy documentation and examples. I'll definitely have to make these things much more clear. If any of you have any ideas about how, or would like to fork away and add your take on it, please do, or let me know what I can do!
Hi there
I have noticed that when creating a view hierarchy using the K({ }) syntax, events attached to a textfield (such as "change", "return", "focus" etc.) don't fire.
if you try a click event on a label however it does work, as is demonstrated in the example docs.
Is this a known limitation or a bug? If it's the former I am happy to fork and dig around and try and fix this up.
PS: I'm really enjoying playing with Kranium. It's a very well thought-out toolkit for making the painful task of interface building with Titanium a little bit more pleasant and productive. Snaps to the devs.