I am used to throw RuntimeExceptions() around my code, to make sure that everything works fine. PDE is catching those exceptions and displaying the error message in a "brown line" above the console. However the problem is that it is only error message, WITHOUT stacktrace. This way it is hard to figure out: what exactly caused the problem... is there a way to tell PDE to show the stacktrace?
In the example below, it would like to know WHO is calling
checkGridBoundsOrThrow() to figure out the cause of error, but without stacktrace I can't.
I am using library which has a method which looks like this
/**
* Submits image in PNG format.
*/
int submitImage(InputStream is);
and I would like to use sketch-generated PImage to submit it to that method. I wonder how can I wrap PImage into InputStream so that I can pass it to the function?
I know that PImage is just bitmap, and that InputStream should provide stream of bytes which conform to PNG-format, this is why this question is kinda difficult! :)
I am making small library which can displays small menu over the running sketch. The menu is triggerred by release of the key INSERT. And whilst menu is displayed to exit from the menu, user has to press DELETE. (I just took for simplicity 2 keys which are not ASCII and rarely used in sketches).
The problem is that whilst menu is on screen, I want it to "consume" all the key events and don't let them propagate into the sketch. Is that something possible?
Please find below some skeleton for the library code:
The library registering itself with methods
parent.registerMethod("draw", this);
parent.registerMethod("keyEvent", this);
Here's some pseudocode from draw()
public void draw(){
if ( mIsMenuDisplayedFlag ){
menu.draw();
}
else{
// do nothing, sketch will run just as usual
}
}
And here's some pseudocode from keyEvent()
/**
* If menu is not displayed, we should wait for "INSERT" key to be released and then we change
* isMenuDisplayedFlag AND CONSUME the event (so that sketch is not receiving it).
*
* If menu is displayed: we should consume all events (when menu is open: no keys should be received by
* sketch) until "DELETE" key is to be released (Becuase ESC key seems to be already used to close the
* sketch window so I don't want confusion and decided my menu to be closed with DELETE)
*/
public void keyEvent(KeyEvent evt){
if (mIsMenuDisplayed ){
// consume all keys until DELETE is released
if ( isReleasedKey(VK_DELETE) ){
mIsMenuDisplayed = false;
}
!!!! CONSUME KEY HERE!!! ? how?
}
else{
// sketch is running as usual, waiting for INSERT to be released to
I want to draw smooth lines on screen with the mouse.
if I do it this way
void draw()
{
line(pmouseX, mouseY, mouseX, mouseY);
}
then the lines wouldn't be smooth (even if instead of line() I would use curve() or curveVertex() it will not take into account all of the points where mouse was. And what's even worse would be frame-dependent.
How to get access to high-resolution mouse movements? (Like those movements which happen between the frames? As far as I understand events are caught in a separate thread (not drawing), so that thread should have very high-precision history of mouse movements somewhere?