Discussion:
Adjust position of calltip if the popup window doesn't fit on the screen.
Paul K
2014-02-12 04:52:59 UTC
Permalink
All,

I use calltips to display function descriptions in my application and
sometimes those descriptions get long. I limit the width of the text to 60
characters (configurable), but when the text is close to the right
boundary, a part of the window is cut.

I'd like to adjust the position of the calltip to the left, but can't
figure out the logic as I don't know the width of the calltip window itself
(although I can probably approximate it based on the width of the text).
Does anyone already have the logic that does this or something similar?

Another related issue is that most of the time the tip is below the text,
but if it's too long to fit the current window, it's shown above the text.
Unfortunately it may still not fit on the screen and it's even worse as you
can't see the beginning of the calltip and the calltip may still fit on the
screen if shown below the text as there may be enough space covering other
windows.

Is there any way to adjust the behavior between showing the calltip above
or below the text? I know about CALLTIPSETPOSITION, but it only sets the
initial preference, but doesn't "lock" the behavior. Thank you.

Paul.
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Paul K
2014-02-12 19:07:01 UTC
Permalink
Neil,
Post by Paul K
Is there any way to adjust the behavior between showing the calltip above
or below the text? I know about CALLTIPSETPOSITION, but it only sets the
initial preference, but doesn't "lock" the behavior. Thank you.

Is there a way to "lock" the position and say "always show below the text"?
It may be sufficient for me to minimize this issue.

Maybe the part of the algorithm that decides to show the tooltip above the
text has to take into consideration not just the Scintilla window size, but
the screen size (if it can)? And abort the change if showing on top doesn't
allow the tooltip to fit on the screen either?

Paul.
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Neil Hodgson
2014-02-13 09:46:45 UTC
Permalink
I'd like to adjust the position of the calltip to the left, but can't figure out the logic as I don't know the width of the calltip window itself (although I can probably approximate it based on the width of the text).
Examine near the end of ScintillaBase::CallTipShow where the proposed rectangle is adjusted to fit on the screen vertically.

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Paul K
2014-02-17 20:01:05 UTC
Permalink
Post by Neil Hodgson
Examine near the end of ScintillaBase::CallTipShow where the proposed
rectangle is adjusted to fit on the screen vertically.

Thank you for the suggestion. I think these two fragments need to be
reversed:

// adjust so it displays below the text.
if (rc.top < rcClient.top) {
rc.top += offset;
rc.bottom += offset;
}
// adjust so it displays above the text.
if (rc.bottom > rcClient.bottom) {
rc.top -= offset;
rc.bottom -= offset;
}

If you first check for top and then for bottom fit and the tooltip is too
large to fit either way, it stays on top with the beginning of the tooltip
cut off, which makes it not readable and largely useless. Checking for
bottom fit and then for the top one will leave it below the line in this
case, which makes it more readable.

I also think that the check should be against GetClientRectangle() first
and then against the screen size. This allows the tooltip to be displayed
correctly if it can fit on top inside the client space, but still be
displayed where it can fit better if it doesn't fit in the client space on
either side.

Paul.
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Neil Hodgson
2014-02-18 00:40:57 UTC
Permalink
If you first check for top and then for bottom fit and the tooltip is too large to fit either way, it stays on top with the beginning of the tooltip cut off, which makes it not readable and largely useless.
While its likely that most uses of calltips will have more important information at the start as parameters, this will not always be the case. For example, some uses may place deprecation/security warnings after the parameters.

I'll reverse the order unless there are objections.
I also think that the check should be against GetClientRectangle() first and then against the screen size. This allows the tooltip to be displayed correctly if it can fit on top inside the client space, but still be displayed where it can fit better if it doesn't fit in the client space on either side.
Some may want the calltip to prefer being outside of the client space so that more contextual text is visible.

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Neil Hodgson
2014-02-20 11:55:06 UTC
Permalink
Post by Neil Hodgson
While its likely that most uses of calltips will have more important information at the start as parameters, this will not always be the case. For example, some uses may place deprecation/security warnings after the parameters.
I'll reverse the order unless there are objections.
Committed as
https://sourceforge.net/p/scintilla/code/ci/e94be36a9d5585b9523fcf6cbd855b427d4f36f4/

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
Loading...