merge code from cocoGUi

 merge code from cocoGUi