Created
November 15, 2012 02:58
-
-
Save ecere/4076369 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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