Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How can I resize my sketch when using ControlP5 Buttons.

$
0
0

I'm very new to processing so please excuse my lack of proper terminology. When I open this sketch and move my mouse over the buttons they highlight and work as expected. When I make the screen much larger all appears ok except when I move my mouse over the buttons they no longer highlight and work unless I move my mouse to what appears to be the old unscaled location of the buttons. Any Idea how to fix this?

Roger.

This is my code. Hope I'm posting it right.

import controlP5.*;
ControlP5 cp5;

PFont font1;

void setup() {

  size(500, 500);
  surface.setResizable(true);

  font1 = createFont("Ravie", 20, true);   

  cp5 = new ControlP5(this);
  cp5.addButton("button1")
    .setCaptionLabel("Button 1")
    .setPosition(100, 200)
    .setSize(125, 50)
    .setColorBackground(0)
    .setFont(font1)
    ;
  cp5.addButton("button2")
    .setCaptionLabel("Button2")
    .setPosition(100, 350)
    .setSize(125, 50)
    .setColorBackground(0)
    .setFont(font1)
    ;
}


void draw() {

  scale( width/500.0, height/500.0);

  background(0);
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles