Android - Custom textview which support text selection and underline - android-custom-view

I want to make custom view or textview, which supports text selection and can also underline part of text string on long press and move-after-long-press events(drag to next line to underline) with different colors of underline. Undelined text can be clickable and get underlined text. I had tried to draw string in canvas and use SpannableString, UnderlineSpan and Clickable Span to draw underline and selection, But failed to get result as required.
Please help! Thank you in advance.

Related

WIN32: Is there a way to have the button icon (BM_SETIMAGE) on the right side of the text

Is there a way to have a button with text and graphic, with the graphic on the right side of the text, without having to owner-draw the button?
I want to just sent BM_SETIMAGE and whatever else would be needed so the graphic is to the right of the text.
Also, I noticed the image is so tight against the text that it doesn't look good. Is there a way to adjust the margin without having to use a blank space in the text?
Is there a way to have a button with text and graphic, with the graphic on the right side of the text, without having to owner-draw the button?
There are BS_LEFTTEXT and BS_RIGHTBUTTON styles available, but the documentation says they only apply to CheckBoxes and RadioButtons:
Constant
Description
BS_LEFTTEXT
Places text on the left side of the radio button or check box when combined with a radio button or check box style. Same as the BS_RIGHTBUTTON style.
BS_RIGHTBUTTON
Positions a radio button's circle or a check box's square on the right side of the button rectangle. Same as the BS_LEFTTEXT style.
For a standard push button, there does not appear to be a way to control the position of the image other than through owner-drawing.
Is there a way to adjust the margin without having to use a blank space in the text?
Use BCM_SETTEXTMARGIN/Button_SetTextMargin():
Sets the margins for drawing text in a button control.

Show CKEditor5 Balloon toolbar programatically on right click?

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.

dotted underline in richtextblock

In Xamarin.UWP, I have created a custom renderer for label using richtextblock. Within the richtextblock, I have used hyperlink to enter text with the ability to click on it. Can I change the underline from straight to dotted?

Auto clear default text in a TEdit

I have a few TEdits on my form. When created they have default text in a gray font color. (e.g. "Surname" and "Name") See example below:
Their on click events causes the default text to be cleared and their font color to be set to black.
My Problem: When I use the tab key to switch between the TEdits the onClick event will not triggered so the TEdit will not be cleared and the font color will stay grey.
Any suggestions on how I can fix this will be appreciated!

Table view cell, custom editor and editing frame

I am using a custom editor when editing the contents of a cell inside a Table view. From the docs I see that the custom editor has to be an NSTextView. So I put the text view in the document view, then I referenced it from the cell subclass through an IBOutlet in order to assign it as custom editor.
When doing all this, I can set the editor not to draw its background, but a thick white border is shown when the user edits that cell, and there is no way to remove it.
So I create the NSTextView programmatically, assigned it as the custom editor, and no white border is shown, but I can't change the background now, set it to clearColor, set the font, fontColor etc. I can't do anything with it. It is just a square with dark background and white text.
Is there something I am not doing? This is a bad approach?
Thank you.
The border is drawn by drawRect:, but I still don't know how to fix it by overriding drawRect:...
You may have a look at this link: http://www.cocoabuilder.com/archive/cocoa/129091-solved-re-disabling-nstableview-big-black-editing-box.html#129259

Resources