Edit AllPages

I am currently trying to create a simple formatting panel like that in programs such as Microsoft Word, where the user can format selected text on the screen, in my case inside an editable General/WebView.

I wish to be able to have buttons that Align the text (Left, Right, Centre and Justified) as well as have a button that shows the Font Panel, and a colour chooser.

I have already made these buttons, and have made the colour chooser using an General/NSColorWell, but now I want to connect the other buttons to do the appropriate actions.

How do I do this? I have had a look at the Blot example in the Developer folder, but am not quite sure how it all works to show the font panel, and justify the text etc. If anyone can show me how it works (even just explaining how Blot works) that would be great. Thanks.