Click Fix
This commit is contained in:
parent
9a5ca4c103
commit
861ed9f13d
|
@ -6,6 +6,9 @@ class GUIWindow : public Window
|
|||
SynButton *buttons;
|
||||
SynText output;
|
||||
SynInputField input;
|
||||
void ButtonCheck(sf::Vector2i);
|
||||
void MouseButtonPressedHandle(sf::Vector2i);
|
||||
void KeyHandle(char);
|
||||
void BinaryButton();
|
||||
void QuaternaryButton();
|
||||
void OctalButton();
|
||||
|
@ -20,11 +23,35 @@ class GUIWindow : public Window
|
|||
public:
|
||||
GUIWindow(unsigned int = 960, unsigned int = 540, std::string = "Window", sf::Uint32 = sf::Style::Titlebar | sf::Style::Close);
|
||||
void Update();
|
||||
void ButtonCheck(sf::Vector2i);
|
||||
void KeyHandle(char);
|
||||
~GUIWindow();
|
||||
};
|
||||
|
||||
void GUIWindow::MouseButtonPressedHandle(sf::Vector2i mousePos)
|
||||
{
|
||||
ButtonCheck(mousePos);
|
||||
}
|
||||
|
||||
void GUIWindow::ButtonCheck(sf::Vector2i mousePos)
|
||||
{
|
||||
int i;
|
||||
SynButton *current;
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
current = buttons + i;
|
||||
if(current -> IsMouseOver(mousePos.x, mousePos.y))
|
||||
{
|
||||
(buttons + i) -> Click();
|
||||
break;
|
||||
}
|
||||
}
|
||||
input.Click(input.IsMouseOver(mousePos.x, mousePos.y));
|
||||
}
|
||||
|
||||
void GUIWindow::KeyHandle(char character)
|
||||
{
|
||||
input.AddToInput(character);
|
||||
}
|
||||
|
||||
void GUIWindow::BinaryButton()
|
||||
{
|
||||
output.SetText(GetBase(input.GetValue(), 2));
|
||||
|
@ -191,28 +218,6 @@ void GUIWindow::Update()
|
|||
window.display();
|
||||
}
|
||||
|
||||
|
||||
void GUIWindow::ButtonCheck(sf::Vector2i mousePos)
|
||||
{
|
||||
int i;
|
||||
SynButton *current;
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
current = buttons + i;
|
||||
if(current -> IsMouseOver(mousePos.x, mousePos.y))
|
||||
{
|
||||
(buttons + i) -> Click();
|
||||
break;
|
||||
}
|
||||
}
|
||||
input.Click(input.IsMouseOver(mousePos.x, mousePos.y));
|
||||
}
|
||||
|
||||
void GUIWindow::KeyHandle(char character)
|
||||
{
|
||||
input.AddToInput(character);
|
||||
}
|
||||
|
||||
GUIWindow::~GUIWindow()
|
||||
{
|
||||
if(buttons) delete buttons;
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
virtual void Update();
|
||||
virtual void ButtonCheck(sf::Vector2i);
|
||||
virtual void KeyHandle(char);
|
||||
virtual void MouseButtonPressedHandle(sf::Vector2i);
|
||||
public:
|
||||
Window(unsigned int = 960, unsigned int = 540, std::string = "Window", sf::Uint32 = sf::Style::Titlebar | sf::Style::Close);
|
||||
virtual void CreateWindow();
|
||||
|
@ -85,11 +86,11 @@
|
|||
else if (event.type == sf::Event::GainedFocus)
|
||||
isFocused = true;
|
||||
else if (event.type == sf::Event::KeyPressed)
|
||||
{
|
||||
KeyHandle((int)event.key.code);
|
||||
}
|
||||
else if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
|
||||
ButtonCheck(sf::Mouse::getPosition(window));
|
||||
else if (event.type == sf::Event::MouseButtonPressed)
|
||||
MouseButtonPressedHandle(sf::Mouse::getPosition(window));
|
||||
// else if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
|
||||
// ButtonCheck(sf::Mouse::getPosition(window));
|
||||
// if(sf::Keyboard::isKeyPressed(sf::Keyboard::F))
|
||||
// {
|
||||
// fullscreen = !fullscreen;
|
||||
|
@ -114,6 +115,11 @@
|
|||
|
||||
}
|
||||
|
||||
void Window::MouseButtonPressedHandle(sf::Vector2i mousePos)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Window::Window(unsigned int width, unsigned int height, std::string title, sf::Uint32 style)
|
||||
{
|
||||
this -> size.x = width;
|
||||
|
|
Loading…
Reference in New Issue