Opened 15 years ago

Closed 14 years ago

#4689 closed enhancement (fixed)

Add shortcuts to StyledEdit

Reported by: ilembitov Owned by: korli
Priority: normal Milestone: R1
Component: Applications/StyledEdit Version: R1/alpha1
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

I believe, StyledEdit could be much more useful if one could choose alignment (or beautifier) by using hotkeys and not by lurking through the menus: e.g., ctrl+b for bold, ctrl+j for justified alignment, etc. Of course, different fonts have different beautifiers, but there are three common ones: bold, italic and underline - those should be accessible through key combinations.

Attachments (3)

stylededit-shortcuts.diff (1016 bytes ) - added by negusnyul 14 years ago.
stylededit-shortcuts-2.diff (3.7 KB ) - added by negusnyul 14 years ago.
stylededit-shortcuts-2-v2.diff (3.6 KB ) - added by negusnyul 14 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by negusnyul, 14 years ago

I'll take a look on this when I will have free time. Looks like a very easy task.

comment:2 by negusnyul, 14 years ago

I attached a patch that adds 4 new shortcuts:

  1. B_COMMAND_KEY + B_OPTION_KEY + R -> Align right
  2. B_COMMAND_KEY + B_OPTION_KEY + L -> Align left
  3. B_COMMAND_KEY + B_OPTION_KEY + C -> Align center
  4. B_COMMAND_KEY + B_OPTION_KEY + W -> Word wrap on/off

With this patch, every significant feature in StyledEdit will have a shortcut except font styles.

About the font styles:

It's doable to add font style shortcuts, but I'm strongly against it, because of these issues:

  1. Inconsistent. Some fonts support bold/italic/underlined/etc. style, some fonts not. It can be annoying for the users that after changing font, some shortcuts aren't working anymore. (And after another change, they're working again - or not: it depends on the font.)
  2. It's a not-so-nice 'hack': We probably need to change some menuitem's shortcut when the user changes the current font (and also take care of cases when there is no bold/italic/underlined styles).

If we want shortcuts for these features anyway, I think we should rewrite the font handling part to a more commonly used style (like in OpenOffice, etc.). However, I think the current solution is OK because StyleEdit is not a full-featured word processor, and shortcuts for these font style functions aren't so necessary at all.

by negusnyul, 14 years ago

Attachment: stylededit-shortcuts.diff added

comment:3 by negusnyul, 14 years ago

patch: 01

comment:4 by axeld, 14 years ago

Even if a font does not have a specific font style, Haiku will automatically create the font, ie. if you set B_BOLD_FACE on a font, it will be drawn bold compared to the plain font, no matter if such font exists or not. IOW having those short cuts would not be inconsistent, just very convenient :-)

Also note that other editors of the "StyledText" can choose fonts, and colors freely, ie. the format does not restrict anything here.

comment:5 by negusnyul, 14 years ago

Even if a font does not have a specific font style, Haiku will automatically create the font,

I didn't know that. Then is there any reason why the user cannot select some styles at some fonts? If not, I'll implement the missing menu points and shortcuts.

comment:6 by axeld, 14 years ago

StyledEdit only shows the actual existing fonts, not the ones that can be computed. What you could do is to add "Bold", "Italic" menu items (underlining is actually not supported in Haiku) which only show the actual style, while the font menu could still just do what it always did.

Manually adding missing entries would also work, of course, though.

comment:7 by axeld, 14 years ago

I've applied the patch in hrev39583, thanks! I'll keep the ticket open because of the other pending things.

comment:8 by negusnyul, 14 years ago

Second (and hopefully final) patch attached.

This patch adds two new menu items to the font menu:

  1. Bold (B_COMMAND_KEY + B)
  2. Italicized (B_COMMAND_KEY + I)
Last edited 14 years ago by negusnyul (previous) (diff)

by negusnyul, 14 years ago

Attachment: stylededit-shortcuts-2.diff added

comment:9 by humdinger, 14 years ago

I tried the patch and it's working very nicely! At last no longer navigating through submenus... Should be committed IMO. However... "Italicized"? Really? :) I'd go with a simple "Italic".

comment:10 by negusnyul, 14 years ago

"Italicized"? Really? :) I'd go with a simple "Italic".

You're right, second version uploaded :) (This is the only difference from the first.)

by negusnyul, 14 years ago

comment:11 by axeld, 14 years ago

Resolution: fixed
Status: newclosed

Applied in hrev39680, thanks a lot! I've made the following changes:

  • Renamed SET_BOLD|ITALIC to kMsgSetBold|Italic - while you just copied what was there (which is usually the safe thing to do), our coding style demands to name constants this way :-)
  • SetMarked() expects a boolean value - and our coding style requires to use != 0 in this case.
  • You missed a space after the if in the message handling code.
Note: See TracTickets for help on using tickets.