Oled menu with u8glib.h library

Please help, i have code for menu like this but not until event clik menu to change page.

#include “U8glib.h”

U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);
//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK);

#define KEY_NONE 0
#define KEY_PREV 1
#define KEY_NEXT 2
#define KEY_SELECT 3
#define KEY_BACK 4

uint8_t uiKeyPrev = 6;
uint8_t uiKeyNext = 9;
uint8_t uiKeySelect = 8;
uint8_t uiKeyBack = 7;

uint8_t uiKeyCodeFirst = KEY_NONE;
uint8_t uiKeyCodeSecond = KEY_NONE;
uint8_t uiKeyCode = KEY_NONE;

void uiSetup(void) {
pinMode(uiKeyPrev, INPUT); // set pin to input
digitalWrite(uiKeyPrev, HIGH); // turn on pullup resistors
pinMode(uiKeyNext, INPUT); // set pin to input
digitalWrite(uiKeyNext, HIGH); // turn on pullup resistors
pinMode(uiKeySelect, INPUT); // set pin to input
digitalWrite(uiKeySelect, HIGH); // turn on pullup resistors
pinMode(uiKeyBack, INPUT); // set pin to input
digitalWrite(uiKeyBack, HIGH); // turn on pullup resistors
}

void uiStep(void) {
uiKeyCodeSecond = uiKeyCodeFirst;
if ( digitalRead(uiKeyPrev) == LOW )
uiKeyCodeFirst = KEY_PREV;
else if ( digitalRead(uiKeyNext) == LOW )
uiKeyCodeFirst = KEY_NEXT;
else if ( digitalRead(uiKeySelect) == LOW )
uiKeyCodeFirst = KEY_SELECT;
else if ( digitalRead(uiKeyBack) == LOW )
uiKeyCodeFirst = KEY_BACK;
else
uiKeyCodeFirst = KEY_NONE;

if ( uiKeyCodeSecond == uiKeyCodeFirst )
uiKeyCode = uiKeyCodeFirst;
else
uiKeyCode = KEY_NONE;
}

#define MENU_ITEMS 4
char *menu_strings[MENU_ITEMS] = { “First Line”, “Second Item”, “3333333”, “abcdefg” };

uint8_t menu_current = 0;
uint8_t menu_redraw_required = 0;
uint8_t last_key_code = KEY_NONE;

void drawMenu(void) {
uint8_t i, h;
u8g_uint_t w, d;

u8g.setFont(u8g_font_6x13);
u8g.setFontRefHeightText();
u8g.setFontPosTop();

h = u8g.getFontAscent()-u8g.getFontDescent();
w = u8g.getWidth();
for( i = 0; i < MENU_ITEMS; i++ ) {

d = (w-u8g.getStrWidth(menu_strings*))/2;*

  • u8g.setDefaultForegroundColor();*

  • if ( i == menu_current ) {*
    _ u8g.drawBox(0, i*h+1, w, h);_

  • u8g.setDefaultBackgroundColor();*

  • }*
    u8g.drawStr(d, ih, menu_strings);
    _
    }_
    _
    }_
    void updateMenu(void) {
    if ( uiKeyCode != KEY_NONE && last_key_code == uiKeyCode ) {
    _
    return;_
    _
    }_
    last_key_code = uiKeyCode;*

* switch ( uiKeyCode ) {*
* case KEY_NEXT:
menu_current++;
if ( menu_current >= MENU_ITEMS )
menu_current = 0;
menu_redraw_required = 1;
_
break;_
case KEY_PREV:
if ( menu_current == 0 )
menu_current = MENU_ITEMS;
menu_current–;
menu_redraw_required = 1;
_
break;_
_
}_
_
}_
void setup() {
_
uiSetup(); // setup key detection and debounce algorithm*_
* menu_redraw_required = 1; // force initial redraw*
}
*void loop() { *
* uiStep(); // check for key press*

* if(menu_redraw_required != 0) {
_
u8g.firstPage();_
_
do{_
_
drawMenu();_
_
}while( u8g.nextPage());_
menu_redraw_required = 0;
_
}_
_
updateMenu(); // update menu bar*_

}