// ====================================================================== // The following are event handler functions // ====================================================================== // Called when a button is clicked void onButtonClick(int componentID){ // If the ">>" button was clicked (RGB -> CODE) if(componentID == rgbToCodeButton){ // Get the values from RED / GREEN / BLUE fields and update color string r = getComponentText(redField); string g = getComponentText(greenField); string b = getComponentText(blueField); setColorByRgb(r, g, b); // If the "<<" button was clicked (CODE -> RGB) }else if(componentID == codeToRgbButton){ // Get the value from the CODE field and update color string colorCode = getComponentText(codeField); setColorByCode(colorCode); } } // Called when the window is closed void onWindowClose(int componentID){ // If the main window was closed, exit the program if(componentID == window){ exit(); } }