Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Carrier: TMN

How to trigger the date selector

Hi everyone!

In my app, I want the user to select a date using the PB browser date selector "dialog".

What I'm trying to do is that by pressing a button, that dialog should popup. But I can't seem to be able to do it. The dialog only appears if the user manually clicks on the date input field.

I tried send focus(), click() and select() , they work but dont trigger the date dialog.

 

Is this possible?

 

thanks

Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.
BlackBerry Development Advisor
oros
Posts: 839
Registered: ‎04-12-2010
My Carrier: Bell

Re: How to trigger the date selector

Hi there,

 

If you check out the dialog_dispatcher.js file that is included with your WebWorks SDK; example:

 

...\BlackBerry WebWorks SDK for TabletOS 2.2.0.5\bbwp\ext\blackberry.ui.dialog\js\common\dialog\dialog_dispatcher.js

 

You can see some references to generateRequest and requestDialog. It may be possible to trace those through to the core functionality and hack something together. From the code though, it does seem to be that a click event should trigger the dialog. I'll play around with this some to see if I can get it working here.

Please note that I will be unavailable between May 19th and June 4th. Sincere apologies for any delays during this time. I will do my best to follow-up as soon as I am able.

Erik Oros
BlackBerry Development Advisor
@WaterlooErik
Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Carrier: TMN

Re: How to trigger the date selector

Hi Erik,

Thanks for the comment!

 

Didn't find anything useful so far. My guess is that this is not webworks related, is how the webkit behaves... probably in some normal webpage the same thing would happen. Maybe someone from the playbook webkit could give a hint on how to trigger it? Any devs around here?

 

Thanks!

nuno

Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Carrier: Vodafone

Re: How to trigger the date selector

<script type="text/javascript">

function onDateTimeSelected(datetime){
  alert(datetime);
}

//Input argument is a reference to an input control of type: date, datetime, datetime-local, month, time
function dateTimeAsync(htmlDateTimeInput) {
  try {
    var opts = { "value" : htmlDateTimeInput.value,
                  "min"   : htmlDateTimeInput.min || "",
                  "max"   : htmlDateTimeInput.max || ""
    };

    blackberry.ui.dialog.dateTimeAsync("date", opts, window.onDateTimeSelected);
  }catch (e) {
    alert("Exception in dateTimeAsync: " + e);
  }
}

</script>  
Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Carrier: Vodafone

Re: How to trigger the date selector

Use that code to call date fucntion e.g

<button id ="test" onClick="dateTimeAsync(this)>Test</button>
Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Carrier: TMN

Re: How to trigger the date selector

Hi Liam,

Yes, that would almost solve it... but according to the API docs, the datetime dialog is only available for BBOS5.0+. I'm on the playbook here :smileysad:

Nuno
Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.
BlackBerry Development Advisor
oros
Posts: 839
Registered: ‎04-12-2010
My Carrier: Bell

Re: How to trigger the date selector

If the user is clicking an input field (or clicking a button), what about some styling on the input field to make it look like a button?

Please note that I will be unavailable between May 19th and June 4th. Sincere apologies for any delays during this time. I will do my best to follow-up as soon as I am able.

Erik Oros
BlackBerry Development Advisor
@WaterlooErik
Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Carrier: TMN

Re: How to trigger the date selector

thanks! that's a clever work-around :smileywink:

my button is on the swipemenu, probably will be harder than that...

Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.