Skip to content

Instantly share code, notes, and snippets.

@ecere
Created November 15, 2012 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecere/4076369 to your computer and use it in GitHub Desktop.
Save ecere/4076369 to your computer and use it in GitHub Desktop.
import "ecere"
class CustomButton : Button
{
bool dragging;
Point dragStart;
bool OnRightButtonDown(int x, int y, Modifiers mods)
{
dragging = true;
dragStart = { x, y };
Capture();
return true;
}
bool OnMouseMove(int x, int y, Modifiers mods)
{
if(dragging)
{
position =
{
position.x + (x - dragStart.x),
position.y + (y - dragStart.y)
};
}
return Button::OnMouseMove(x, y, mods);
}
bool OnRightButtonUp(int x, int y, Modifiers mods)
{
if(dragging)
{
dragging = false;
ReleaseCapture();
}
return true;
}
}
class Form1 : Window
{
caption = "Form1";
background = activeBorder;
borderStyle = sizable;
hasMaximize = true;
hasMinimize = true;
hasClose = true;
clientSize = { 576, 392 };
CustomButton button1
{
this, caption = "Test", position = { 8, 8 };
};
}
Form1 form1 {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment