I want to click a text on the panel with a underline and the text color is blue, and then show a web , I know how to show a web , but how to define the text , in nib when I put a label on the window , I found the label didn't respond for the action , when I put a button with no border I found that I didn't edit the text attribute of the button , which module should I put on that and how to edit that text attribute?Thanks a lot.
The impact I want to show is : http://stackoverflow.com
You could use an NSTextField with attributed text marked with NSLinkAttributeName.
Check out this Apple example http://developer.apple.com/qa/qa2006/qa1487.html
Why don't you add a WebView and then you can put html directly in there?
Related
I use CkEditor BalloonEditor:
BalloonEditor.create(document.querySelector('#editor'), { ...options... });
By design the balloon toolbar of CkEditor 5 is only shown when I mark some text in the editor. That's totally okay for standard text operations as making a text bold, italic or changing its colors.
But if I want to insert something (image, table, media) I first must type something, mark it, so that the toolbar is shown before I can insert new content. That is not practical. So actually the balloon editor is great for changing existing content, not to insert new content.
My idea now is, that I want to open the toolbar by clicking with the right mouse button, showing the toolbar instead of the browser's context menu. Nice would be if the toolbar then only contains actions to insert new content (as inserting image, table, media) and the actions for formatting content (as bold, italic, font color) disappears or at least are disabled.
So basically I would implement something like:
<div id="editor" oncontextmenu="showContextMenu(event)">
...
function showContextMenu(event) {
event.preventDefault();
// --> Open here the balloon toolbar at the current caret position. How?
}
I tried finding a solution with a hack:
When clicking with the right mouse button, I inserted a space character at the clicked position and marked/selected it automatically so that the CkEditor balloon editor opened the toolbar. That worked so far, but then I had this undesired space character in the document and I struggled to remove it gracefully afterwards. Furthermore the context menu also contained the text formatting actions (as bold, italic and so on, since there was text - the inserted space selected).
Another idea would be to develop an own toolbar completely detached from CkEditor and then using Commands to insert the appropriate commands as #denov has suggested in his solution. But I think this should actually be possible to achieve with the CkEditor API by using the class ContextualBalloon. But how?
Does anyone have any idea how to achieve this or can guide me with some directions?
Thx!
For images you can just drag the image into the editor.
Commands are the way to interact with the editor. The Images plugin uses the ImageInsertCommand
assuming you have the editor assigned to the global window object you could do
function showContextMenu(event) {
event.preventDefault();
window.editor.execute('imageInsert', { source: 'https://upload.wikimedia.org/wikipedia/commons/8/8d/Frog_on_palm_frond.jpg'} )
}
Unfortunately, it's not possible to show the balloon toolbar if the selection is collapsed. This behaviour is defined here.
I am, no matter what I try, unable to change the back button colour and default image.
Here is what it looks like rite now:
The leftmost arrow is the default and the right most is my custom arrow.
This is how I set it up in storyboard:
How do I remove that pesky default image and replace it with my own?
The button you are adding is overriten by the default back button provided by the navBar. The only way you could do that is by adding it from within the code and by creating an UIButton inside the UIBarButton with an image and/or text, you should set its action a popViewController.
I made a PushButton to open up a Font Panel like they did here:Make NSButton open fonts panel
I did all of these through the Interface-Builder by dragging buttons and Labels onto the MainMenu View and i have nothing inside my AppDelegate.h and .m
Im really new to objective c and cocoa so i was wondering if anyone could give me an in depth explanation on how to use that font panel to edit the font in a Label or a Text Field.
Both label and text field are class NSTextField.
The style of the text they display is determined by the attributes on their NSAttributedString.
The Attributed String Programming Guide on Apple's developer site goes into detail on how to handle attributes. The font is one of those inside an attribute called paragraph style.
That should get you started on what to look into.
The Cocoa text architecture is pretty rich and can take some time to get familiar with.
One thing to note, when a text field is in edit mode, it uses something called the field editor for rendering , which is normally a shared instance of NSTextView that is owned by the window and basically appears in front of the text field during editing.
Is it possible to use a label at a toolbar?
I would like to display a number in a label. It is easy in a view but now I want it to be displayed in the toolbar.
I can drag a label to the toolbar, no problem, but the content is not visible there, even if the name Label is visible in the IB.
More info: If I drag a label into toolbar on an single view it works perfectly to display any text or number in the label even in the toolbar.
But the problem I seem to have is it does not work at a toolbar if the view is a scrollview!!
Buttons, bar buttons, no problem, but just the label does not show up when I run the app.
Why are the toolbar items behaving differently if the view is a scrollview?
It is better not to use a label for a toolbar but a UIBarButtonItem. Then you select in IB plain style and you can display the text in title.
I made a button with IB then added custom images for different states but my title never appears on my button. How can I fix it? In fact, I just want to add my text over the image.
You can set your button images as background images in interface builder, then the text will appear.
It will not appear because the image is on top of it, you can either:
1) Use backgroundImage instead of image
2) Create an image with the text already on it
3) Create a button with a transparent part where the text will go
4) Have your image and your text in the button, but say one on the left and one on the right, you can do this with this properties: titleEdgeInsets and imageEdgeInsets
5) Add the label and uiimage as subviews of uilabel.
start with a regular button type in the title and switch it to a custom button, if you want the background to be changed import and use the command yourButton.backgroundColor = [UIColor grayColor];
Try to change the Button type to "Custom" and then add the image as Background Image. Now u will be able to see the desired look.