www.digitalmars.com         C & C++   DMDScript  

D - DIG onMouseOver

reply "Charles Sanders" <sanders-consulting comcast.net> writes:
Im having trouble getting Labels to respond to the onMouseOver, heres the
code.  Am i missing a step ?  It works for Frame, but doesnt seem to for
buttons / labels .  Thanks, Charles.

import net.BurtonRadons.dig.main;

 class Program : Frame
{

 void MouseOver() { messageBox("Hey","Hey"); }

 this ()
 {
  with (new Label(this) ) {

   caption("Hey a link");
   onMouseOver.add(&MouseOver);
  }
  width(50);
  height(20);
 }
}

void main ()
{
 (new Program).showModal ();
}
Aug 03 2003
next sibling parent "Charles Sanders" <sanders-consulting comcast.net> writes:
Also having some display trouble with ListBox, given the following code:

import net.BurtonRadons.dig.main;

 class Program : Frame
{


 this ()
 {
  super();
  caption ("Hello program");

  ListBox x = new ListBox(this);

  x.left(10);
  x.top(15);
  x.width(300);
  x.height(100);
  x.addColumn("Test column 1",100);
  x.addColumn("Test column 2",100);
  x.addText("Heythere", "stupid");

  width(400);
  height(150);
 }
}

void main ()
{
 (new Program).showModal ();
}


It displays, but then not completely, I have to slide the first column all
the way to the right to display the entire control, then sliding backwards
slides it back out of view, tested with Windows 2000 and XP.

Also can we have an addText method for just one column ?

"Charles Sanders" <sanders-consulting comcast.net> wrote in message
news:bgk95q$eru$1 digitaldaemon.com...
 Im having trouble getting Labels to respond to the onMouseOver, heres the
 code.  Am i missing a step ?  It works for Frame, but doesnt seem to for
 buttons / labels .  Thanks, Charles.

 import net.BurtonRadons.dig.main;

  class Program : Frame
 {

  void MouseOver() { messageBox("Hey","Hey"); }

  this ()
  {
   with (new Label(this) ) {

    caption("Hey a link");
    onMouseOver.add(&MouseOver);
   }
   width(50);
   height(20);
  }
 }

 void main ()
 {
  (new Program).showModal ();
 }
Aug 03 2003
prev sibling parent Burton Radons <loth users.sourceforge.net> writes:
Charles Sanders wrote:
 Im having trouble getting Labels to respond to the onMouseOver, heres the
 code.  Am i missing a step ?  It works for Frame, but doesnt seem to for
 buttons / labels .  Thanks, Charles.
This is because it's a native control, so I'm not being given the message that's translated by the window system. I'm going to turn it into an emulated control in the next version, although I should change the way messages are processed too. If you need it before then, you can use this untested code: import net.BurtonRadons.dig.main; class LinkLabel : Canvas { this(Control parent) { super(parent); onPaint.add(&doPaint); doublebuffer(false); } void doPaint() { beginPaint(); clear(backgroundColor()); textFont(font()); textPrint(0, 0, captionValue); endPaint(); } /** Assign the caption and repaint the control if it changed. */ void caption(char[] value) { if (value == captionValue) return; captionValue = value; recalculate(); } override void recalculate() { textFont(font()); suggestWidthAndHeight(textWidth(captionValue), textHeight()); } /** The current caption. */ private char[] captionValue; } class Program : Frame { void MouseOver() { messageBox("Hey", "Hey"); } this() { with (new LinkLabel(this)) { caption("Hey a link"); onMouseOver.add(&MouseOver); } width(50); height(20); } } void main() { (new Program).showModal(); }
Aug 03 2003