Skip to content

CODED is not supported #209

Open
Open

Description

@gaocegege

key is a char, and CODED is a int, I don't know how to compare those two things

fillVal <- 126

draw <- function() {
  fill(fillVal)
  rect(25, 25, 50, 50)
}

keyPressed <- function() {
  print(key)
  print(CODED)
  if (key == CODED) {
    if (keyCode == UP) {
      fillVal = 255
    } else if (keyCode == DOWN) {
      fillVal = 0
    } 
  } else {
    fillVal = 126
  }
}

Activity

  1. jeremydouglass commented on Aug 14, 2017

    @jeremydouglass
    Member

    Java automagically converts the char to an int for comparison -- for example, this works:

    final int CODETEST = 99;
    println(CODETEST);
    int myKey = 'c';
    println(myKey);
    if(myKey == CODETEST){
      println("equal");
    }
    

    If this isn't working in R, perhaps due to precedence (?), then perhaps try:

    Option 1: change CODED in the list of constants to a char type

    Option 2: convert before check:

    (key == as.character(CODED))
    
  2. jeremydouglass commented on Aug 6, 2019

    @jeremydouglass
    Member

    Option 1: change CODED in the list of constants to a char type

    Thinking about this further, I think that option 1 -- changing CODED to a char in Processing.R -- is the way we should go. The only way that CODED is used in the Processing API is to compare it to key, so this preserves the Processing style of writing

    if (key == CODED) {
    

    which is what we want. The char(CODED) value in Java should be equal to in renjin something like:

    CODED <- as.character(65535)
    
  3. added this to the v1.0.8 milestone on Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions