XUL alert box with Yes/No instead of OK/Cancel?
16 posts
• Page 1 of 2 • 1, 2
Hi,
I use <code>nsiPromptService.confirm()</code> to prompt the user often, but the buttons "OK" and "Cancel" aren't really appropriate. The appropriate answers are always "Yes" or "No". Is there any way to display a prompt with Yes/No buttons? The <dialog/> element doesn't seem to be much help -- there doesn't appear to be a way to change the text of the buttons it displays. Is the only solution to create my own <window/> with <button/> elements in a new XUL file??? Thank you for any advice, grimholtz nsIPromptService::confirmEx is the appropriate way to do this. You can see an example in QuickNote (current dev, quicknote.js, note delete confirmation).
BTW, you can change dialog buttons' captions Interesting. I had tried confirmEx() but always got a prompt with a checkbox. I'll take a look at your code. Thanks.
Just pass null for checkMsg parameter and the checkbox won't show. For you and those who may find this thread in future, here's the code that makes a dialog with customized button labels, but without teh checkbox:
Follow up: don't check that
Clarification: BUTTON_TITLE_* set title for given button when passed in buttonFlags. You pass a sum of products of form (BUTTON_TITLE_.. * BUTTON_POS_..). BUTTON_TITLE_* sets title for the button specified with BUTTON_POS_*.
IHoss, excellent tutorial. I wish you would have contributed it to the Example Code Knowledge Base, though!!
![]() That's what I was going to say. I've added it to that page already.
I tried asking somewhere else about how I can add pages to the knowledge base but I got no reply. Thats why I haven't added it.
It's easy. First, you need to register, then log in (it's all done on the login page linked from top-right corner).
Then to edit a page, click the [edit] link at the top of the page. To add a new article, add a link to it from an existing page (by typing [[Article name]]), then save the page and follow the (red) link. aha, cool! Thanks, ill do that now then
![]() Thanks for the comments too btw. If you find any spelling mistakes (more than likely) just give me a nudge and I'll fix it ![]() What's cool about wiki is that others fix the minor mistakes for you (well, eventually they do).
Do the ps.BUTTON_POS_X flags for button positions vary from platform to platform? What if I want the "yes" button on the left on Windows and on the right for the Mac? I don't think you can do that. Linux has it opposite to windows and I don't think you can change it. If you say "flag = 4*256+3*1;" then it will take the sum and not care what order it is in. It will put the yes and no where it is apropriate. The only way to change it would be to set the title of the buttons as strings with locale values.
16 posts
Page 1 of 2 • 1, 2
Return to Extension Development Who is onlineUsers browsing this forum: No registered users and 0 guests |
![]() |