c# - Tooltip only shows after moving the mouse -


i'm having trouble show tooltip using mousemove event. basically, want show tooltip when mousepointer on regions of picturebox. i'm trying accomplish using mousemove event, determining wether pointer on sweet spot , (if so) setting tooltip using settooltip.

this mousemove event (as i've noticed mousemove continuously triggered when tooltip shown, check if position changed or not)

private void pbfaseflow_mousemove(object sender, mouseeventargs e) {     if (e.location != oldposition)     {         oldposition = e.location;          // determine text tooltip (gets loaded global string)         determinetext(position);          // show coords , tooltip text debugging in textbox         tbinfo.text = e.x.tostring() + " " + e.y.tostring() + " " + tooltiptext;          // show tooltip         if (tooltiptext != string.empty)         {             tooltip.settooltip(pbfaseflow, tooltiptext);             tooltip.active = true;         }         else         {             tooltip.active = false;         }     } } 

this working fine, except when move mouse sweet spot first pixel. in textbox, can see text being determined (say "test" f.e.), tooltip not show. after move mouse 1 more pixel tooltip shown. problem, because on sweetspots can 1 pixel wide, tooltip doesnt show when moving mouse on left right (it show, when moving up/down..)

even when i'm not checking position has changed, (i omit e.location check), tooltip not show until move mouse 1 more pixel.

i noticed if never make tooltip unactive, work, don't want show outside sweetspots..

what happening here?

---------- edit --------------

some more information :

when change code (basically showing tooltip, except single space when there's no information), tooltip updates on sweet spots. disadvantage have empty tooltip showing time when there's no data show, pretty annoying.

            // show tooltip             if (tooltiptext != string.empty)             {                 tooltip.active = true;                 tooltip.settooltip(pbfaseflow, tooltiptext);             }             else             {                 tooltip.active = true;                 tooltiptext = " ";                 tooltip.settooltip(pbfaseflow, " ");             } 

looks you're missing tooltip.show() method.

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms;  namespace windowsformsapplication1 {     public partial class form1 : form     {         private point oldposition = new point(0, 0);         private point ptsweetspot = new point(30, 30);         private list<point> sweetpointarea = new list<point>()              { new point(60, 60), new point(60, 61),                new point(61, 60), new point(61, 61)             };          public form1()         {             initializecomponent();              pbfaseflow.mousemove += pbfaseflow_mousemove;              //just see on picturebox             bitmap mybitmap = new bitmap(pbfaseflow.height, pbfaseflow.width);             mybitmap.setpixel(ptsweetspot.x, ptsweetspot.y, color.red);              foreach (point p in sweetpointarea)             {                mybitmap.setpixel(p.x, p.y, color.green);             }              pbfaseflow.image = mybitmap;         }         private void pbfaseflow_mousemove(object sender, mouseeventargs e)         {             if (!e.location.equals(oldposition))             {                 oldposition = e.location;                  // show coords , tooltip text debugging in textbox                 tbinfo.text = e.x.tostring() + " " + e.y.tostring();                  //are inside sweet area?                 if (sweetpointarea.contains(e.location))                 {                     tooltip.active = true;                     tooltip.settooltip(pbfaseflow, "hello sweet area!");                     tooltip.show(tooltip.gettooltip(pbfaseflow), pbfaseflow, pbfaseflow.width / 2, pbfaseflow.height / 2);                 }                 //no? maybe we're on sweet spot?                 else if (e.location.equals(ptsweetspot))                  {                     tooltip.active = true;                     tooltip.settooltip(pbfaseflow, "hello sweet point!");                     tooltip.show(tooltip.gettooltip(pbfaseflow), pbfaseflow, pbfaseflow.width / 2, pbfaseflow.height / 2);                }                 //no? ok, disable tooltip                 else                 {                     tooltip.active = false;                 }             }         }     } } 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -