You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Piotr Kołaczkowski <p....@sages.com.pl> on 2011/10/27 20:31:47 UTC

DialogBoxes with default buttons

Hi,

I want to do a really very simple thing - a dialog box with a form in it 
and two buttons: OK and Cancel. I want the OK button to be pressed by 
default when user hits the Return (Enter) key and Cancel when the user 
presses Esc. Additionally, the OK button should be somehow highlighted 
(e.g. different color or border), so that the user knows this is the 
default. Is there some builtin support in Pivot for doing this, or do I 
have to do it manually, by programming all the events, etc? This is 
probably a very common case, and as far as I remember, even Delphi in 
year 1998 had something like that - it was just as simple as setting the 
DialogBox mode to "modal" and assigning each button a modal-result.

Regards,
PK


Re: DialogBoxes with default buttons

Posted by Greg Brown <gk...@verizon.net>.
http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/DialogStateListener.html

On Oct 27, 2011, at 3:49 PM, Piotr Kołaczkowski wrote:

> Thanks.
> And how to call a listener, e.g. for validation, before closing the dialog in response to hitting "Enter"? This validator should have the ability to cancel closing the dialog.
> 
> Regards,
> Piotr
> 
> W dniu 2011-10-27 20:41, Greg Brown pisze:
>> You don't need to do anything special to achieve this. A dialog will close automatically with a result of true when the user presses Enter. It closes with a result of false when the user presses Escape.
>> 
>> You could use styles to highlight the OK button as the "default".
>> 
>> On Oct 27, 2011, at 2:31 PM, Piotr Kołaczkowski wrote:
>> 
>>> Hi,
>>> 
>>> I want to do a really very simple thing - a dialog box with a form in it and two buttons: OK and Cancel. I want the OK button to be pressed by default when user hits the Return (Enter) key and Cancel when the user presses Esc. Additionally, the OK button should be somehow highlighted (e.g. different color or border), so that the user knows this is the default. Is there some builtin support in Pivot for doing this, or do I have to do it manually, by programming all the events, etc? This is probably a very common case, and as far as I remember, even Delphi in year 1998 had something like that - it was just as simple as setting the DialogBox mode to "modal" and assigning each button a modal-result.
>>> 
>>> Regards,
>>> PK
>>> 
>> 
> 
> 
> -- 
> Piotr Kołaczkowski
> senior consultant
> Sages Sp. z o.o.
> ul. Wąwozowa 11
> 02-796 Warszawa
> t: +48 22 2035600
> f: +48 22 2035601
> m: +48 609618449
> 


Re: DialogBoxes with default buttons

Posted by Piotr Kołaczkowski <p....@sages.com.pl>.
Thanks.
And how to call a listener, e.g. for validation, before closing the 
dialog in response to hitting "Enter"? This validator should have the 
ability to cancel closing the dialog.

Regards,
Piotr

W dniu 2011-10-27 20:41, Greg Brown pisze:
> You don't need to do anything special to achieve this. A dialog will close automatically with a result of true when the user presses Enter. It closes with a result of false when the user presses Escape.
>
> You could use styles to highlight the OK button as the "default".
>
> On Oct 27, 2011, at 2:31 PM, Piotr Kołaczkowski wrote:
>
>> Hi,
>>
>> I want to do a really very simple thing - a dialog box with a form in it and two buttons: OK and Cancel. I want the OK button to be pressed by default when user hits the Return (Enter) key and Cancel when the user presses Esc. Additionally, the OK button should be somehow highlighted (e.g. different color or border), so that the user knows this is the default. Is there some builtin support in Pivot for doing this, or do I have to do it manually, by programming all the events, etc? This is probably a very common case, and as far as I remember, even Delphi in year 1998 had something like that - it was just as simple as setting the DialogBox mode to "modal" and assigning each button a modal-result.
>>
>> Regards,
>> PK
>>
>


-- 
Piotr Kołaczkowski
senior consultant
Sages Sp. z o.o.
ul. Wąwozowa 11
02-796 Warszawa
t: +48 22 2035600
f: +48 22 2035601
m: +48 609618449


Re: DialogBoxes with default buttons

Posted by Greg Brown <gk...@verizon.net>.
You don't need to do anything special to achieve this. A dialog will close automatically with a result of true when the user presses Enter. It closes with a result of false when the user presses Escape. 

You could use styles to highlight the OK button as the "default".

On Oct 27, 2011, at 2:31 PM, Piotr Kołaczkowski wrote:

> Hi,
> 
> I want to do a really very simple thing - a dialog box with a form in it and two buttons: OK and Cancel. I want the OK button to be pressed by default when user hits the Return (Enter) key and Cancel when the user presses Esc. Additionally, the OK button should be somehow highlighted (e.g. different color or border), so that the user knows this is the default. Is there some builtin support in Pivot for doing this, or do I have to do it manually, by programming all the events, etc? This is probably a very common case, and as far as I remember, even Delphi in year 1998 had something like that - it was just as simple as setting the DialogBox mode to "modal" and assigning each button a modal-result.
> 
> Regards,
> PK
>