Listen to a value change of my text field

You can set a delegate for your NSTextField instance and have the delegate implement the following method: – (void)controlTextDidChange:(NSNotification *)notification { // there was a text change in some control } Your delegate object can be the application delegate, a window controller, a view controller, or some other object in your application. The delegate can … Read more

Creating a custom event listener on an Android app

Define a callback interface public interface NewsUpdateListener { void onNewsUpdate(<News data to be passed>); } Provide a registration facility on the background thread which gets the RSS feed class <Background processing class name> { …. ArrayList<NewsUpdateListener> listeners = new ArrayList<NewsUpdateListener> (); …. public void setOnNewsUpdateListener (NewsUpdateListener listener) { // Store the listener object this.listeners.add(listener); } … Read more

Add multiple window.onload events

Most of the “solutions” suggested are Microsoft-specific, or require bloated libraries. Here’s one good way. This works with W3C-compliant browsers and with Microsoft IE. if (window.addEventListener) // W3C standard { window.addEventListener(‘load’, myFunction, false); // NB **not** ‘onload’ } else if (window.attachEvent) // Microsoft { window.attachEvent(‘onload’, myFunction); }

How can I remove a JavaScript event listener?

You need to use named functions. Also, the click variable needs to be outside the handler to increment. var click_count = 0; function myClick(event) { click_count++; if(click_count == 50) { // to remove canvas.removeEventListener(‘click’, myClick); } } // to add canvas.addEventListener(‘click’, myClick); You could close around the click_counter variable like this: var myClick = (function( … Read more

How to Register Pluggable Database(PDB) with new created LISTENER

Connect to an idle instance and startup the instance [oracle@ol8-19 ~]$ sqlplus / as sysdba SQL> startup; change container to that pluggable database SQL> alter session set container=pdb; Session altered. and open it SQL> alter pluggable database pdb open; Now, you set local_listener SQL> alter system set local_listener=”(address=(protocol=tcp)(host=ol8-19.localdomain) (port=1522))” scope=spfile; System altered. and issue the … Read more

How to create a proper Volley Listener for cross class Volley method calling

For your requirement, I suggest you refer to my following solution, hope it’s clear and helpful: First is the interface: public interface VolleyResponseListener { void onError(String message); void onResponse(Object response); } Then inside your helper class (I name it VolleyUtils class): public static void makeJsonObjectRequest(Context context, String url, final VolleyResponseListener listener) { JsonObjectRequest jsonObjectRequest = … Read more

On date change listener

Yes you can listen to date / time changes on Android. For this, register a BroadcastReceiver for the following intent filters explicitly in your Activity: android.intent.action.ACTION_TIME_TICK This Intent is sent every minute. You can not receive this through components declared in your manifest, but only by explicitly registering for it with Context.registerReceiver(). Your Receiver (inner) … Read more

Get back key event on EditText

Thank you Reno. It probably seems to work, but I managed to solve it differently. I overrode EditText’s onKeyPreIme(int keyCode, KeyEvent event). This method intercepts keypresses on the IME. =D public boolean onKeyPreIme(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { // do your stuff return false; } return super.dispatchKeyEvent(event); … Read more