ScintillaNet - detect mouse over - scintilla

is it possible to react when the mouse is over a word ? Suppose I want to show a bubble with a description of the thing I'm currently hovering. Seems strangely difficult to do.

I think it is possible but might be a little hard.
You have the MouseHover event however you don't know what word you hovered so it might be a little hard.
You can get the mouse localization with this:
Point mouseLocation = new Point(e.X, e.Y)
Then if you use a fixed-width type font you know the size of each line/character then you can calculate it.
Some code that helps with position/line transition:
var line = scintilla.LineFromPosition(startPos);
startPos = scintilla.Lines[line].Position;
scintilla -> Control Name
For a better view try seeing this:
https://github.com/jacobslusser/ScintillaNET/wiki/Custom-Syntax-Highlighting
https://github.com/jacobslusser/ScintillaNET/wiki/Basic-Text-Retrieval-and-Modification
Edit:
Not really a good answer soo 2nd try
[scintilla name].CurrentPosition -> you can get the word you selected if I'm not mistaken but I don't know if you can do it by hovering.
Then do the interpretation of the word and it might work.
Try reading this:
https://github.com/jacobslusser/ScintillaNET/issues/149

3rt Try.
Let's hope it's the best one.
https://github.com/Ahmad45123/AutoCompleteMenu-ScintillaNET
There is AutoCompleteMenu for Scintilla that has a hover property.
I'm not sure how it works but might be what you're searching for.

Related

JavaFX: Cross-Platform Button Resizing Issue [duplicate]

If I make button relatively small, it's caption turns to ellipsis.
How to turn off this feature?
Don't let the button go below it's preferred size, then it will never need to elide the text of the button label:
button.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE);
I want to make very small button
You can use any of the below either separately or in combination:
Apply CSS to use a very small font in the button.
Make the label text for the button very short.
Use brian's answer which proposes explicitly setting the ellipse string to empty.
Use a small graphic icon instead of text.
You can use setMinSize as documented above in all cases (if you wish the button not to go below a preferred size truncating or eliding content).
In all cases, if you wish, you can also apply CSS to minimize the padding between the label and button the border.
From your previous comment (I want to use simple captions like "<" and ">"), I think option 2 (Make the label text for the button very short) is what you want.
You may also be interested in Joel's Designing for People Who Have Better Things To Do With Their Lives which would indicate, usability-wise that very small buttons are usually a pretty bad idea.
in your label/button you can use the textOverrun property to turn off ellipsis.
textOverrun.set(OverrunStyle.CLIP);
this is probably a bit late for you, so i am putting it here for lone wanderers digging up this question.
It puts ... because there's no room for the text. You can use bigger buttons or a smaller font but if you really want the dots gone use button.setEllipsisString(""); , but then you just get truncated text.

GTK: How to make labels as buttons (sort of list)

In GTK+ I would like to have a vertical list of labels, that a user can scroll. A user can click on any label and it will go to it's own callback function.
Right now I'm using a vertical area of buttons, but I really do not like having buttons. To give a good example, what I am trying to achieve would be considered very similar to a ListView in Android:
Is it possible to achieve this? I have tried replacing my buttons with labels but the signals stopped working (which would make sense). The GtkList is depecrated, and I am not sure what I am supposed to use instead?
I think you can use GtkTreeView with GtkListStore ( GtkTreeSelection for selection in GtkTreeView ). For scrolling of course you will make use of GtkScrolledWindow. Using GtkTreeView can be a little intimidating for a beginner but there are quite a few tutorial available online like this one. Also, if you can install gtk-demo application (part of gtk2.0-examples package on Ubuntu) which demonstrates using Gtk widgets along with code, it will be quite helpful for you.
Hope this helps!
What you could do as well (if you really want to use labels) is to just put each of them into a GTKEventBox, and then set the event mask to receive mouse clicks.
EDIT:
Example:
GtkWidget* gtk_clickable_label_new(const gchar *str)
{
GtkWidget *eventbox, *label;
label = gtk_label_new(str);
gtk_widget_show(label);
eventbox = gtk_event_box_new();
gtk_widget_add_events(eventbox, GDK_BUTTON_PRESS_MASK);
gtk_container_add(GTK_CONTAINER(eventbox), label);
return eventbox;
}
Have you tried putting your labels in a GtkVBox in a GtkScrolledWindow?
I think what you want is a bunch of GtkButtons that have no hieght/depth.
To do this use gtk_button_set_relief and choose the GTKReliefStyle of GTK_RELIEF_NONE.
That's how I put buttons in GtkTreeViewColumn headers, it looks nice.
Try it!

Getting Windows Phone 7 WebBrowser Component VerticalOffset

I want to persist the user's location in the document he or she is browsing, then bring them back to that spot when they return from tombstoning or between sessions.
My first approach was to wrap the browser component in a scrollviewer, but it turns out it handles its own scrolling and the scrollviewer never changes its verticaloffset.
My guess is that the browser component must have a scrollviewer or something like it embedded in it. I need to get the verticaloffset and scroll to an offset.
Any guesses how to get there?
My next approach would be a painful mish-mash of javascript and c# to figure out where they are...
Because of the way the WebBrowser control is built you'll need to track scrolling in Javascript then pass the location to managed code to handle storage of that value.
On resuming you'll need to have the managed code pass the scroll position to a Javascript function to reset the scroll position.
That's the theory but I haven't looked at the funcitonality around javascript scrolling events in the WebBrowser yet. That's the only place I can see possible problems.
Would be good to hear how you get on.
I've accepted Matt's answer, but I want to put in some details here. I'm also going to blog about how I did it once I'm completely done.
Since the WebBrowser component is essentially a black-box, you don't have as much control as I would like. Having said that, it is possible to get and set the vertical offset.
Javascript lets you ask for the value, but different browsers use different variations on HOW to ask. For THIS case I only have one browser to worry about.
First I make a couple of simple javascript functions:
function getVerticalOffset() {
return document.body.scrollTop;
}
function setVerticalOffset(offset) {
document.body.scrollTop = offset;
}
Next I call into the WebBrowser using the InvokeScript method on the browser object.
I'll post an update here with a link to my blog when I get the full write-up done.
I have been writing an eBook reader and had a similar question. Code for setting a scroll position has been easy enough to find.
Code for setting vertical scroll position:
string script = string.Format("window.scrollBy(0,{0});", "put your numeric value here");
wb_view.InvokeScript("eval", script);
Google didn't help much in finding solution for getting the value of current scroll position. Lacking any knowledge in javascript it took me almost two hours to get it right.
Code for getting the vertical scroll position:
var vScroll = wb_view.InvokeScript("eval",
"var vscroll = window.pageYOffset; vscroll.toString();");

Changing Win32 menu colors

Is there a way to change the colors used by plain Win32 menus (background, text, and highlight) for a single process, without using SetSysColors?
(SetSysColors does a global change, which is bad, and if you crash or forget to set the colors back with SetSysColors again before exiting, they will not be restored until you logout.)
The SetMenuInfo() API is your friend. It lets you apply any brush to paint your menu's background.
Something along these lines should solve your problem:
MENUINFO mi = { 0 };
mi.cbSize = sizeof(mi);
mi.fMask = MIM_BACKGROUND|MIM_APPLYTOSUBMENUS;
mi.hbrBack = hBrush;
HMENU hMenu = ::GetMenu(hWnd);
SetMenuInfo(hMenu, &mi);
If I believe your comment to Rob, it is for a skinned application, with special look and feel. So the way to go is probably indeed, as ferek points out (in an unfriendly way...) to use owner-drawn menus: you will be able to define precisely their look.
I have to ask, why? Adopting the regular Windows look-and-feel is good; it means users can be confident that there are consistent elements in your user interface, onto which they can map their experience using other software for the platform.
[I'm probably preaching to the converted, of course, but I thought I'd make the point so anyone who reads an answer for this doesn't start making all their menus sky-blue-pink 'cause it looks pretty.]

Symbian S60 - Scrolling text in a CEikLabel

I have a single line CEikLabel in my application that needs to scroll text.
The simple solution that comes to mind (but possibly naive) would be something like..
[begin pseduo code]
on timer.fire {
set slightly shifted text in label
redraw label
}
start timer
[end pseudo code]
Using a CPeriodic class as the timer and label.DrawDeferred() on each update.
Do you think this is the best way, it may be rather inefficient redrawing the label two or three times a second.. but is there any other way?
Thanks :)
I've seen the timer based solution used for scrolling item names in listboxes.
A couple of things to watch out for are that it could flicker a bit while scrolling and that you need to make sure the text you put on the label is not too long, otherwise it will automatically clip the string and add an elipsis (...)
Use TextUtils::ClipToFit to get a string that fits on the label and remove the elipsis it adds before putting the text on the label (search for KTextUtilClipEndChar in your clipped string). You will need to work out how many characters to skip at the beginning of the string before passing it to the clip function.
I don't know whether there is another way to do it and can't say whether the approach you have in your mind will be inefficient. However, you may want to take a look at this thread which discusses pretty much the same question as yours and also briefly mentions somewhat the same solution as the one you have conceived of.
I have done it like this
TTimeIntervalMicroSeconds32 scrolltime(70000);
iPeriodicScroll = CPeriodic::NewL(CActive::EPriorityIdle);
iPeriodicScroll->Start(scrolltime, scrolltime, TCallBack(CVisTagContainerView::ScrollTextL, this));
and then in the repeated function
CEikLabel *label = iContainer->Label();
const TDesC16 *temp = label->Text();
if (temp->Length() <= 0) {
if (iTextState != ETextIdle) { return; }
DownloadMoreTextL();
return;
}
TPtrC16 right = temp->Right(temp->Length()-1);
label->SetTextL(right);
label->DrawDeferred();
So text moves right to left, and when all gone, the label is repopulated by DownloadMoreTextL

Resources