View::performClick add SoundEffect

This commit is contained in:
houzh 2023-11-20 15:39:28 +08:00
parent a24a1d6340
commit 1bee5f2235
4 changed files with 9 additions and 5 deletions

View File

@ -56,8 +56,8 @@ static void endElement(void *userData, const XML_Char *name){
}
void Preferences::load(const std::string&fname){
std::ifstream fin(fname);
if(access(fname.c_str(),F_OK)==0){
std::ifstream fin(fname);
mFileName=fname;
load(fin);
}else if(fname.find("<sections>")!=std::string::npos){

View File

@ -6070,8 +6070,10 @@ void View::setHovered(bool hovered) {
}
bool View::performClick(){
if(mListenerInfo && mListenerInfo->mOnClickListener)
if(mListenerInfo && mListenerInfo->mOnClickListener){
playSoundEffect(SoundEffectConstants::CLICK);
mListenerInfo->mOnClickListener(*this);
}
return mListenerInfo!=nullptr && mListenerInfo->mOnClickListener!=nullptr;
}

View File

@ -3311,7 +3311,7 @@ bool ViewGroup::performKeyboardGroupNavigation(int direction){
if (cluster && cluster->isRootNamespace()) {
// the default cluster. Try to find a non-clustered view to focus.
if (cluster->restoreFocusNotInCluster()) {
//playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
playSoundEffect(SoundEffectConstants::getContantForFocusDirection(direction));
return true;
}
// otherwise skip to next actual cluster
@ -3319,7 +3319,7 @@ bool ViewGroup::performKeyboardGroupNavigation(int direction){
}
if (cluster && cluster->restoreFocusInCluster(realDirection)) {
//playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
playSoundEffect(SoundEffectConstants::getContantForFocusDirection(direction));
return true;
}
return false;

View File

@ -1814,7 +1814,9 @@ bool ListView::handleHorizontalFocusWithinListItem(int direction) {
bool ListView::arrowScroll(int direction) {
mInLayout = true;
bool handled=arrowScrollImpl(direction);
const bool handled=arrowScrollImpl(direction);
if(handled)
playSoundEffect(SoundEffectConstants::getContantForFocusDirection(direction));
mInLayout=false;
return handled;
}